Under IOC and AAU rules, you can self-identify (to the organizers; it needn't be public) as transgender, in which case you can compete as the opposite sex*, so presumably it becomes completely legit. Not sure how that affects ISU and USFSA, but they probably follow the same rules. It is quite possible that some Olympic medalists have secretly been transgender - the IOC doesn't allow release of that info.
But! IOC has other rules that might discourage you - last I checked transgenders must have surgery and hormone treatments.
As far as pretending to be the opposite sex, at most lower level competitions, no one checks competitor's genders - but if someone knew the parties involved, there might be a challenge and a public outcry. Indeed, if you had reason to believe someone was pretending, and you didn't inform the officials, perhaps you might be banned or disqualified yourself, just as Carolina Kostner was banned for not reporting her boyfriend for using performance enhancing drugs.
At the upper levels, very few ladies, hormones, surgery or no, have the strength and relative jump and shoulder width to look like a man. Very few men, hormones, surgery, or no, are able to move with the grace and range of hip motion expected of ladies. (Might not apply to young kids.) I think that if you self-identify as transgender, you should be judged like the opposite sex too. E.G., if a guy can look and move like Meryl Davis at her most alluring best, that might be good enough.
See also:
http://skatingforums.com/index.php?topic=6748.msg81584#msg81584OTOH, no matter what the rules say, most people consider it an unfair advantage for a man to compete as a lady, in any sport involving strength or endurance. I've now decided it IS unfair too, though I know some disagree, and I don't matter. Create separate categories, as some here have noted, and forego fairness issues - though of course those who want their status secret would hate that.
*When I say that they compete as "the opposite sex", I may not be using the language in the same way as transgenders who consider themselves to actually
be of the sex that they self-identify as.