Fireworks are a tough one. Ear plugs or some aggressive noise cancelling headphones are about it, because people loooove their boom pops. I had to go to an NFL game recently and my AirPod Pros were a lifesaver.
For entertaining, I've just started asserting myself (excrutiating, but the brief social embarrassment is worth the longer stress of dealing with the circus). It's honestly easier these days because a) I'm older and starting to realise most people I hang out with will take it in stride and b) I am lucky to have extremely low pressure family and friends. So this might not work for you but I hope it might.
If you can't be 100% honest, tell people you get stressed easily - they usually understand that. Or if they're selfish, that you have a migraine (which I would get from the anxiety of an upcoming event, so not necessarily a lie for me). Migraines have a similar look & feel and if you prime them to accept that you have one, they are more likely to roll with it if you need to disappear and decompress for a while.
I also like the other poster's suggestion of helping prepare food or clean up. It gives you something to focus on and takes you out of the main event. People will appreciate not having to do the work themselves so they can enjoy the party. It's a win-win.
Finally, if you need a shield, offer to take photos. It's not glamorous, but personally I am far more comfortable staying to the sidelines and hiding behind the camera. Just remember to follow through and upload the best photos to a cloud drive to share with everyone.
