A possible approach is the sandwich technique.
Here's one way to adapt it.
Hey John! Good to see you!
I hope you don't mind if I don't talk much today, I've got this work to finish.
Oh, no need to leave, it's good to have company, I just can't talk right now.
You've got a couple things going on; I'll try to separate them.
First of all is your desire to be left alone. Second is your desire to not be rude or to offend people.
I'll start with the non-offensive part first. Part of the challenge here is: what do you normally portray yourself as? Are you always trying to be left alone? Do you only want to interact ...
I realize this answer may cover things you didn't ask about - but bear with me - they may be connected.
I read your question as a request for having some quiet time on your own, without being unnessecarily rude. There is nothing wrong with that at all, but it makes me wonder if you've given a thought to how you want your relationship with your co-workers to ...
Even if they ask I don't feel like saying don't sit with me due to it is usually considered rude. They asking either what's wrong or got offended.
When I can feel that the other person who sat on the chair next to me is kinda stuck in a conversation, and just carrying it on, I tell them up front not to feel bad about leaving the conversation. I tell them ...
I've only been in this situation once (a case of plumber pants), but it occurs to me that you might want to first try an anonymous approach that does not appear to target any particular person. I prefer to try humor at first, and so posting notices along these lines suggests itself to me:
I've seen London, I've seen France
But I don't wanna see your ...