It’s a complicated one and you’ve presented as a simple binary choice here. Teachers have a duty of care and this means they get information a lot, some of which has to be cascades to safeguarding leads. If a teacher believed that telling parents their child was LGBTQ+ would lead to a risk of immediate significant harm, then they wouldn’t. That would be managed carefully and a referral would already have been made to social services.
However, teachers only care for children weekdays between 8 and 4. The rest of the time those children are with their parents or elsewhere. That’s a problem, because if a child is struggling and the teachers withhold information they become complicit in the withholding of information. Sharing information is a core part of child protection because it allows someone to have the big picture and act objectively. Safeguarding children requires sensible middle ground thinking.