No, it's not legal, it's discriminatory.
Think of one of those posh men's clubs in London, biological men only, no biological women allowed to join.
Then imagine if they said they also welcomed 'individuals who feel comfortable in a men-only space'. And allowed biological women who 'identify' as biological men to join.
This would discriminate against biological women who don't 'identify' as men.
In law, there is only biological sex, male or female, - and 'identifying' as the opposite sex is sheer fantasy and wishful thinking.