You need to tell him that you don't like his behavior in dog language. That means, you don't tell him "no" (that's human language), but use gestures and timing to communicate.
I'm taking all the information given in this question by the same user into consideration, so the answer covers more scenarios than in the question posted here.
The most appropriate gesture in this case is to gently push him away from you. Use either your hand, arm or leg for this. This is especially effective if he tries to sit on your feet or rub against your legs. You can also extend your leg into the direction of the dog to keep him from approaching you or food on the table. Just let him walk against your foot and don't give any room.
Don't be rude! Excert just enough force to make him understand that he is supposed to move away from you, but don't shove him around or even kick him.
Alternatively, you can pull him away by the collar. Simply grab the collar, extend your arm sideways and let go at the maximum extension of your arm. There's no need to make him sit down or otherwise interact with him. You just force him away from the object of his desire.
Again, use the appropriate force to move him away without yanking or choking him.
If his behavior is rude (like jumping or scratching people or putting his head on a table to steal food), you should prod him in the side like described in this answer. The most effective place to prod is the flank between the ribs and thigh, but if that's unavailable, any place at the side of his body will suffice.
This gesture is the equivalent of smacking the hand of someone who steals a cookie, so it's appropriate to chastize rude behavior, but not minor transgressions. If you cannot reach down to prod him with your hand, you can use your food instead, but please don't kick him.
A light tap to the side (like demonstrated here at 0:35) is efficient to interrupt behavior like barking without punishing the dog. It can be as light as when you pet him, but is just a tap instead of a petting stroke.
The timing is of utmost importance when training dogs. You must correct unwanted behavior within 3 seconds or it becomes futile, but it's most effective within the first second.
You should also set clear rules with the dog and every family member involved. If you chastize him for scratching your legs, your grandma shouldn't allow the same behavior. I know from your original question that the owners won't adhere to those rules, but the rest of the family should.
When the dog initiates unwanted behavior, react immediately with the appropriate gesture. If you can read his body language good enough to know that he will do something unwanted in a second, that's the best moment to correct him.
I'll try to break it down a little bit...
- You sit down to talk to your grandma. Dog looks at you - nothing happens
- Dog walks up to you without touching you - nothing happens
- Dog walks in front of you to sit down on your feet - you push him away from you with your feet
- Dog sits besides your legs but doesn't touch you - nothing happens
- Dog lays his head onto your leg to beg for food - you push him away with your knee
- Dog lifts his paw to scratch at your legs - you prod him
- Dog jumps on your lap - you gently shove him forward until he has to jump down (jumping up and being shoved down should be one fluid motion)
No dog understands new rules at the first try. You'll have to correct him over and over again, but with some patience on your side, he will learn. Even old dogs can still learn polite behavior.
Offering an alternative
The optimal way to correct this behavior (almost seems hyper-active to me) would be to offer an alternative that can calm the dog down. The best solution would be to place a pillow or blanket in a corner of the room, a few meters away from the people talking. You would teach the dog to go to this place and stay there during the meal or until he's calmed down. As mentioned above, I don't see any chance of this happening with the dog's owners...
An alternative is to keep him busy with slow games. There are toys like a Kong (filled with a food paste) or kibble dispenser balls that keep the dog entertained for a while, but if he gets treats thrown at him every 5 seconds, his interest in actually working for his treats will be zero.
If you start correcting the dog's behavior, you make yourself less interesting for him. If his owners don't change their behavior, they are still as interesting as before. The dog will probably interact with them all the time (and vice versa) and the humans can talk with each other if they manage to ignore the dog and owners.
Sorry to be so pessimistic, but the real problem here is not the dog, it's his owners. If you cannot change them, you cannot fundamentally change your family gatherings.