THIS IS OF COURSE NOT LEGAL ADVICE I AM NOT A LAWYER I AM JUST A GUY CONSIDERING THIS ON THE INTERNET
In my story, my MC ends up hosting a known (and common) alien life form within their head to keep it alive by joining with another sentient being; as a result, both host and alien life form's personality is infused while it's still inside her. This was done on dubious consent due to the death of the original host and the MC being the only compatible host and the alien can't live too long out of a host or stasis.
I think the same principle as duress would apply here IF the alien life form themselves was the perpetrator, at least in parallel. If you go and borrow money from someone, only for them to chase after you with a gun demanding their money back and your only reasonable way to get away was to steal someone's motorcycle, whether you could apply a duress defense depends on who that guy you borrowed money from is. If you had a reasonable belief that he was an upstanding guy, then you could apply the duress defense. If you knew he was an SOB, you couldn't claim duress because you should have known what you were getting yourself into.
It is eventually removed but part of it is left behind and (unknowingly) grows into another generation of it's kind but it more parasitic and suppresses more of the host personality than the original alien. This caused the MC to commit a crime on impulse (eg; started a war by blowing up another ship as a preemptive strike). If the MC hadn't had the alien there, the likely chance of committing the crime would have been significantly lower and unlikely to have happened.
This makes it more probable that a duress defense would succeed on paper. If this parasitic personality thing was not known to occur before the MC dealt with it, then her lawyer would be able to cogently argue something duress adjacent (as noted in several previous answers, it would be easy to say that the MC had no mens rea, and she couldn't bear responsibility for the situation if there was no reasonable way to foresee the consequences thereof).
However, as pointed out by @David258:
A war has been started, this tends to be taken pretty seriously. It's almost impossible to conceive that there won't be an enormous amount of political interference in this trial. The result will set an enormous legal precedent, be appealed in the highest courts, drag on for years/decades and likely lead to the creation of new laws.
For your story, this generates a lot of plot. Anyone who thinks your MC is a threat (like, say, your antagonist, or more insidiously, people whose aims are lined up with hers but who think she's a dangerous element for starting a war) or who have something against those aliens and want to create some kind of precedent to make hosting them illegal-- or else under some kind of controlled system-- will have ample reason to try to make the trial about crucifying the MC: the legal precedent would be worth way more than mere gold. Conversely, people who want to help your MC aren't just her friends: the aliens, for one, are going to be VERY invested in making sure any trial goes her way, and even people who may not like the MC personally may try to help her trial because they are incentivized to make sure that the alien hosting is legal.
Basically, because there are lots of cogent legal theories that the MC could cite in her defense, but pretty much all of them are active defenses, and because the actions of the MC are very politically significant, this is going to be a politically dictated trial more than a legally dictated trial unless your judge and jury are very, very impartial. This can be great for your story if you need to generate a major plot point. It can also be terrible for your story if it starts taking away from other major plot points.