Well, it kind of depends what you mean by legally change gender!
Any one of us is freely able to use any prefix to our names that we like, so long as it is not done fraudulently. For example, you can happily call yourself Mr, Miss or Ms but not Prof or Dr (unless you happen to be a Prof or Dr).
As far as identity is concerned, my specialist writes to people like the Passport Office detailing how it's a permanent change and they then issue my Passport, Driving Licence etc in the correct gender (yes, your Driving Licence indicates your gender - most people don't know how, though)
After two years, I can apply for a new birth certificate and all my old records are destroyed.