Yes, but not in anything resembling canon
It happened during the The Curse of Fatal Death, which was a Comic Relief parody of Doctor Who. Joanna Lumley, of Ab Fab fame, played The Doctor.
In the normal show, however, it remains a possibility, at least according to Moffat:
"One day I'm reasonably confident somebody in this [showrunner] role - whether it's me or someone else - will say not, 'Let's cast a woman', they'll say, 'That person, that's the one who could the be the Doctor'. You're just casting someone that you think will set that role on fire. I think for now that is Peter - I thought it was Matt [Smith] before - it's not about the gender thing."
In-universe, The Doctor refers to The Corsair as specifically swapping genders. He's mentioned in the regular series during The Doctor's Wife:
DOCTOR: The mark of the Corsair. Fantastic bloke. He had that snake as a tattoo in every regeneration. Didn't feel like himself unless he had the tattoo. Or herself, a couple of times. Ooo, she was a bad girl.
So in-universe it can happen, out-of-universe it has been alluded that it might happen specifically for The Doctor