Union rep here. Your school cannot prevent you from joining a union and, as echt commented, you do not have to tell them. Even if they ask you directly, you do not have to tell them - GDPR.
A few years ago, we got a new HT. She talked the talk about wanting regular meetings with me as the union rep, maintaining good relations with staff etc. At our first meeting, her opening question, pen poised over clipboard was, "So who is in your union, then?" I refused to tell her, and she never arranged another meeting. To this day, I'm convinced that she only set up the first one to try to find out who was a member. (Incidentally, this is the reason why union subs cannot be gathered by payroll - management could easily find out who was in.)
Our big drive right now is to get a Trade Union Recognition Agreement. This means that over 50% of the teaching staff in the school - and it doesn't have to be the same union, it can be a combination - vote in favour. Management then has a legal obligation to consult on changes, rather than simply imposing them in dictatorial fashion like now.
Being in a union is very important. I know it's expensive, but the first year is sometimes free and there are reductions for PT staff. Think of it as an insurance policy in case something goes wrong.