Is it ok to masturbate if you have athlete's foot fungus on your hands?

Sure. This fungus seldom causes problems on the genitals, either male or female.
Fungal infection. A fungal infection in your hands is contagious to yourself and to other persons you touch. That answers your question.
Get treatment. It is important to have the fungal infection on your hands treated, it is not expensive, but left untreated will damage the nails and invite other infections. You are not more likely to get fungus on your penis by masturbating than you are already at such risk.
Obviously, no. Like every thing else in life, good hygiene means washing your hands thoroughly before engaging in this activity.