What's the best way to prevent trench foot when in a cast?

Keep foot dry. I haven't seen a case of trench foot as a result of casting. Trench foot is the result of prolonged exposure to wet environments. Keep the cast dry. If the cast does get wet, see your physician since the cast should be replaced.
Keep it dry. Trench foot generally happens when a person is immersed in water for long periods of time like soldiers in a war or a scenerio like that. The average person in a cast is not exposed to extreme conditions like this. Keep the cast dry and you should be fine.