Honestly, I think the current answer is we don't know.
Right now, in the current world, we see many thousands of people telling us "I may have been born with a penis, but I am a woman." Some people accept that, some people don't. I personally accept it, to some degree.
I think sex is your genitals, and gender is more of a mind or brain thing, and I think both are quite possibly objective facts. But I don't think we yet have the means to measure gender. We haven't quite discovered, yet, how to tell that this person born with a penis is a boy based on his brain physiology, and this person born with a penis is a girl based on her brain physiology.
I think it's theoretically possible, but for now all we can go on is self-reporting.
The other big alternative to this imo is that gender is entirely a social construct, and that choosing to identify as a woman is the same thing as being a woman. I think this point of view has a host of problems that I'm not sure I can go into here, but I don't think it's true, and I actually think this point of view is possibly anti-trans.