A few thoughts:
- Look for a remote job?
- This one seems silly, but... care less about whether you are productive and focus on whether you are happy at work
- Have a discussion with your manager about how to mitigate the annoyances
- Also have a discussion with your manager about how to do more of the stuff you like
- Set stronger boundaries - a sign which says please do not disturb me when headphones are on for example may help to reduce small talk, if that's something you don't desire, and allows you to start/stop focus time. Talking with your coworkers about how best to interact with you like telling them that you prefer conversations start with an email thread, or a message on slack/teams/etc.