There are cases where it makes sense.
Such as during pride month to help gay students who are often badly bullied feel welcome by school officials probably reducing feelings of isolation, depression, and to reduce suicides.
Also perhaps there is a school club for gay students or gay straight alliance clubs.
A problem with banning pride flags is that it is a strong signal to teachers to self censor about anything gay in any teaching context.
Such as sex education, history, sociology, the arts, etc.
Basically a don't say gay policy without the need to pass an explicit law about.
BTW this issue was addressed on the latest episode of the tv comedy sitcom The Conners.