I'd rather disclose after the job offer (if I have to--really depends if I can get my markers changed by then). However, if they run a background check after the interview, but before giving the offer, it may be best to explain things (incongruent markers) first...
I guess it depends on how the particular company conducts hiring. I don't really know what the 'standard protocol' is for hiring, regarding background checks (when they do it, how in-depth they go, whether name changes or gender marker are revealed). Don't suppose anyone here worked in hiring or HR at some point, who could shed some light on things?