It wouldn't be unsafe. A lot of people have dreams where they are a different gender and they don't act any more feminine or masculine. Dreaming of being a different gender isn't going to change your testosterone or estrogen at all

Theres absolutely no harm I can think of.