In most states, if your driving privileges are taken away, in the form of your driver's license being suspended or revoked, due to medical reasons you need to obtain medical clearance to get your license back. It sounds as if you were cleared by the doctors but were driving before going to the DMV to get your driving privileges reinstated and received a ticket for doing so.
State laws differ so to find out what penalties you will receive for driving with a revoked license try contacting the court listed on the citation you received. Also the Department of Motor Vehicles for your state may also be able to give you information on this violation and the penalties assigned to it.
Here are some examples of what state penalties are for driving with a suspended or revoked license:
Kansas - It is a class B non-person misdemeanor to drive without a valid license. This is punishable by not less than five days imprisonment, not to exceed six months, and at least a $100 fine, not to exceed $1,000.
Virginia - The maximum penalty for a first offense of driving with a suspended or revoked license is a jail sentence of 6 months, a $1,000 fine,
Massachusetts - Driving while your license is suspended or revoked is considered a criminal motor vehicle violation. You may face a considerable fine and/or jail sentence, as well as additional suspension sanctions, for doing so.
Taking your information to court from your doctors showing that you are now clear to drive may help your case but likely you will still have some penalties placed on you for the citation you received.