Whether it is legal or not to drive with a broken ankle in a cast is up to state laws so you would need to check with your state's Department of Motor Vehicles or like agency.
If you have your foot operated on or it is broken so that a cast is needed then if you have an automatic vehicle normally you can drive within a few days if your foot is comfortable enough is the medical advice we received. Otherwise doctors normally suggest that you wait until the ankle is strong and flexible enough to work the pedals, especially in an emergency situation - this may take up to 6 weeks or more.
There might be a state law or statute prohibiting from a driver operating a vehicle if they are temporary disabled in such a way that would make them an unsafe driver or if it is ill advised by a doctor. If you are medically not advised to drive with a broken ankle in a cast it would be best if you did not drive your car until given medical clearance.
If you drive your vehicle and the ankle does keep you from operating the vehicle properly and you end up in an accident depending upon state laws you may be cited for unsafe operation of the vehicle.
You may also want to contact your insurance agent to see if they have any guidelines regarding when drivers have their legs, ankle, or foot in a cast and to make sure you would not be driving against the terms of your policy.