One of my colleagues in my previous org was forcibly asked to resign. She asked for a two month notice period to look for other jobs, and didn’t work at all the entire two months. The company also couldn’t do anything in this case because the only other option is to terminate her, which would mean they have to pay the severance.
As far as a bad experience letter is concerned, you can inform your new HR/Hiring Manager about the harassment you were facing by your previous employer regarding the same. I’m not a legal person, but I’m pretty sure the company cannot and won’t file a lawsuit because they wouldn’t win in court and also because it can go public and ruin the reputation entirely. That would be more expensive for the company than paying severance.
In the end, if the company wants to let you go, they will let you go either way. You can either resign as per their conditions and leave on a good note or you can fight back and burn all the bridges. I’m sorry to say this, but sadly that’s the only way.