In my experience, saying no is useless. Here's why.
The damage has been done
If you have to say something like "No, I'm sorry, this is a bad time," that means someone has already disturbed you by asking "Do you have a minute?". For me personally, that's enough to get me out of the zone. So I just don't bother with saying no and I help the person who disturbed me to get it over with. Otherwise, there'll be a chance that they'll come back later and get me out of the zone a second time.
Unless you find some way to stop people from even asking if you have a moment, there's no point in dismissing them because the very act of asking you this, is enough for you to lose focus.
So how can you prevent being disturbed?
This is easy if you have a private office. Just tell everyone that if your door is closed, you would like to be left alone and that they're welcome to drop by whenever it is open.
If you work in an open landscape office (like me) where you're in the same room with multiple people (6 in my case), that's a lot harder. You could use some sort of token. Something like a red flag you can attach to the side of your monitor. Whenever the red flag is up, people should know that you don't want to be disturbed. The only thing you have to pay attention to, is that the flag isn't up all the time. Otherwise people will still disturb you because they won't take it seriously.
So basically it means that you have to make agreements with everyone in your office on when people can and cannot be disturbed.
If you have to say no
Now, I'm going to try and answer your question anyway. How can you actually dismiss someone in a polite and subtle way? Well, if the person you're dismissing is a developer as well, I guess he'll understand you. They'll likely know the situation and respect that. In fact, I think everyone would understand that. Even managers have situations when they're in some sort of zone and don't want to be disturbed. I wouldn't worry to much about it. Just make sure that you're polite (don't sound irritated), tell them you're in the middle of something difficult/important and either ask them to come back in XX hours, tell them you'll come to them in XX hours, or ask them if they ask their question over email.
So the rules are:
- Polite (no irritation)
- Explain (tell them why not)
- Commitment (tell them when will be a good time and keep to it)