For whether it is legal, I refer to Bob Brown's answer and focus on the other part in my answer on whether it affects one's career. Note that I will use the term 'trans people' loosely, including anyone who might want/need to explicitly proclaim their preferred pronouns (e.g. indlcuding androgynous people, intersex people etc. who did not switch from one gender to another), for this answer.
Will picking a fight with your professor regarding explicitly announcing your pronoun have any impact on your career?
Very likely, yes. However, the effect is likely minimal or small.
Why? Your professor has already shown that they have a strong opinion in this matter or feel externally compelled to enforce this rule. If you pick a fight, no matter whether you "legally" win and can avoid following the rule, chances are the relationship with the professor is soured at least temporarily. The professor might be biased against you should you take further courses with them. They might not want to work with you in the future, either because they consider you a bad apple for not following the same political agenda or for just considering you difficult for making a fuss about such a non-issue (at least in their view) and this might restrict your options regarding bachelor or master theses or further TA work etc. with this professor. If it is quickly resolved with the professor (potentially via a quick answer from the higher body the issue will be escalated to), the effects will likely not go beyond direct decisions of your professor. The most likely short-term effect could be that you are fired from your TA role or at least not re-hired next term.
Note that your professor might also be perfectly reasonable/tolerant or calm down after a short time of annoyance and this might have no effect at all. It all depends on their character and how further escalation is handled by all parties. But there is always risk and there are multiple parties involved that you have no control over.
However, generally speaking, the higher the issue is escalated, the broader the involvement of other professors and administrators gets and the larger public impact it has, the more likely are broader long-term effects. Or sudden effects after a long term, e.g. if at some point someone wants to publicly denounce you and digs through your past. (See the stories for people being sacked / getting their university admission rescinded due to racial slurs used in the past for example; note: using this just as an example that hot social topics can be dug up and used against people, not saying this is somehow the same as these cases in any way). While non-participation in a well-intended gesture should in my mind have no repercussions beyond a head-scratching of why anyone would not go along, this is currently a hot social topic and unfortunately discussed in a very partisan style, where "both sides" too often read little deviations from their preferred ideology with a "you're not fully with us, so you're against us" mindset. However, since you're a TA, this is also a workplace issue and as such turns this from only a gesture into an issue of following proper workplace procedure as outlined by your superior (see also below). Even if only your current professor holds this against you, the professors at your university might exchange opinions about students, especially when it comes to student jobs like TAs. They need to make getting a bachelor and master thesis possible, but they do not need to provide you TA or other job opportunities, so these are more likely to be affected by bad mouth to mouth press.
So, if you want to go through with resisting your professor's wishes, you should aim at a quick resolution that is as local as possible to minimize any negative impact. If you have another discussion with your professor, consider to bring up arguments from the answers here, like questioning whether it makes sense to force people to proclaim their pronoun taking into consideration the people they aim to support. E.g. as @Serge pointed out in a comment, some transgender people might themselves prefer not to disculse their preferred pronouns. I'd suggest to argue from their point of view, i.e. does the policy make sense in its strict form especially considering trans people and the goal to support them. There is also a certain likelihood your professor is themselves only following a guideline imposed on them. In that case arguing the guideline with them will help little. You either need to address the source or indeed find a way for an individual excemption. So first establish whether the professor acts on their own or whether this is a university thing. This will also establish how far up you could need to escalate.
With respect to the long-term effects, it would in principle be possible that the tides shift and in a more "conservative" future having a track record of resisting a pro-trans-people move could be a benefit in some way. I'd consider this unlikely, but to be complete this can be considered too.
In any case, all that I can offer (and I'd say anyone as I doubt there are statistics, but if there are, they'd be welcome) is a personal estimation of likelihood and reasoning of how people might react. Neither of us can foretell the future, it's a hot topic in general but also a small issue by itself. It can blow up or just disappear and you laugh about it in a year.
Perception
While I personally feel your professor's approach is at least a bit misguided (see below), whether the approach is perfectly correct is not that relevant, it will be perceived as a well-intended attempt to be inclusive of trans people. Currently this seems to be a strong agenda in the US especially in academics (outside perspective, happy if anyone can provide data to back this up or counter it). So any resistance to such a policy will more likely be seen as negative than positive. In addition, to most people resistance to provide basic obvious information when asked by your employer, i.e. fill out forms correctly, will seem ridiculous. It is you who reads more into this than the average person. While the average person might find providing pronouns odd, picking a fight with a superior at work about giving (in most people's eye) obvious information like your name when filling out a document will seem way more odd to them and thus they will rather consider you a weird trouble maker than side with you. And yes, as a TA you are (should unless you don't get payed) now in a work relationship with your professor, not in a student relationship, where you mostly can do whatever you want as long as you learn something. Now you partially represent the professor and the university and thus there is a stronger expectation that you do as told unless that's particularly unbearable (discriminatory, illegal etc.). So, even people who have no investment into the general topic will see picking a fight over a (to them) non-issue like providing an obvious gender explicitly rather than have people implicitly derive it as an indication of a trouble-maker. So without deeper discussion, people leaning towards a pro-trans agenda as well as people who are not involved at all will likely lean to have a negative impression about you. This may influence their reaction to you, willingness to support you or work with you.
Why do I think the professor's approach is misguided?
The goals likely are 1) a symbolical gesture to show acceptance of trans people 2) to make it psychologically easy for anyone that doesn't have an 'obvious' gender identity to announce it and 3) to further the acceptance of trans people and specifically of announcing gender identity explicitly.
At least my hope would be that those would be the goals (or similar ones) rather than implementing the rule simply because it seems en vogue.
My personal problem with the approach taken is that it apparently tries to force compliance rather than convince everyone involved to participate voluntarily. Because
- that partially invalidates 1) - it's way less of a meaningful gesture if people are forced, can still be seen as a gesture on the university level, but none that I would value much of an academic institution
- it works against 3) - forcing people to do something in the name of an agenda or group typically breeds resentment against that agenda/group
- and it insults the academic spirit of raising free thinkers that rather use argument to advance their position than power.
Pick your battles wisely
As always, you need to pick the battles you want to fight wisely. So you might want to decide to swallow this issue and pick another battle at another time. The following might help in accepting this.
Reconsider your own perception
Your main problem with accepting to state your preferred pronouns seems to be that you read that as supporting a trans-oriented view with arbitrary genders/genders up to be chosen rather than assigned at birth/tied to biological sex. Remember how I noted above that too many people treat this topic black and white? Try to not read adding your preferred pronouns as supporting everything any pro-trans movement proclaims as their goals. Otherwise how different is it for any pro-trans person to read your decision not to go along as a rejection of all they stand for - including the acceptance of them in society and academia (which you apparently DO support).
If you look at it pragmatically, if you risk a fight now, you either loose it (nothing gained) or you win and you don't need to put your pronouns, but someone could find out about it, write an article about the bad conservatives that are so anti-trans they don't even want to put their pronouns on a form for some construed reason -> laughter and sympathy points for the trans community.
You can also consider it a courtesy towards trans-people that you as a generous person does explicitly despite not agreeing with their ideology (or what you perceive as such, because there likely isn't one they all support). Like saying Merry Christmas to Christians although you're not yourself or the like. Talking French to the French tourists (although in your mind it might be their job to learn English when travelling to America) etc.
What about the old formal address using Mr/Mrs? Would you consider selecting these as explicit support for a conservative model,too? Then most trans people do show support for that model every day when ordering stuff online, give them some support back ;)
What if this will simply be the replacement for the old Mr/Mrs model? How is it different from extending that model to Mr/Mrs/Other/...?
Whether you need to consider yourself a hypocrite or feel a conflict with your religious convictions in this case largely hinges on your perception of the underlying meaning of the action to explicitly state your pronouns. That is something you can easily change. Not just because it makes accepting to follow the professor's wishes more easy, but because it indeed is more or less arbitrary. Yes your view is kinda valid (but also confrontational by nature), so is the one I sketched here or some answers and comments assume. Be the better person in being non-confrontational and give people the cookie they want.
If you want to fight this battle, support them and make friends
If you do want to go ahead with a confrontation, my suggestion would be to not make that about you individually but what is best for your institution. Does your institution really want to force TAs to declare their gender identity? Would that be in the best interest of trans-people? Do you have some sort of student council where you could discuss this? If a student representation body would make a counter-proposal that explicitly asks to provide pronouns voluntarily rather than mandatorily, that would be a strong argument for your case.
You could e.g. take a bet and offer a compromise in that you go ahead with the policy if it is supported by the students. Then organize a feedback evaluation where you make sure rejecting to force TAs to declare their pronouns is an option. For instance there could be options like "would you support a university policy that forced every TA to declare their pronouns to make it easier for transgender people to do so too? For or against this policy" and separately "would you support a policy that encouraged/allowed TAs to declare their pronouns to make it easier for transgender people to do so too? For or against this policy". Obviously a gamble, but perhaps serving the majority wishes would also make it easier for you to accept the policy should the feedback turn out that way. Note, I'd only go this way with either support from a student representation group and/or having it discussed with the professor(s) first. If you do your own evaluation behind their backs, that might win you the battle but escalate the issue and breed resentment on their end.
Another important aspect, stay polite and to the point. Don't get sidetracked or tempted to make any general statements that could then be read as discrimination against trans people (or any other group). Don't make things personal, don't attack your professor. Things are typically easier forgotten or set aside if they were politely handled and about an issue than if people feel personally attacked. At least on the local scale. When you consider escalating, first make sure you are up to that and will be able to control yourself and what you say. The higher you escalate the more likely that anything you say will be used against you by someone.