The thyroid produces hormones that (among other things) regulate your metabolism. An imbalance of these hormones could lead to a weight gain. It may be that you need to change your dosage of medication or perhaps switch to a medication that is more suited to your body. I suggest that you consult an endocrinologist.
Have you noticed other symptoms, such as more/less energy, feeling warmer/colder than usual, using more/less salt on your food?