Try, whenever possible, to refrain from yawning; if you must do so, cover your mouth with your hand and mutter an apology.
Don't inflict your fatigue on other people - if you're too tired to socialise without a gaping mouth and watering eyes, you should be tucked up in your bed. It is even more offensive to yawn out of boredom; if you're reduced to a state of jaw-aching tedium, and you can't disguise your feelings of boredom, then it's best to make your excuses and go before your behaviour causes real offence.
Remember, even if your reasons for yawning are bona fide (a night of insomnia, a red-eye flight), people will tend to interpret your yawning as a blatant expression of boredom, and will inevitably take offence.
Yawning is infectious. If you don't want to reduce your companions to an eye-watering, jaw-aching stupor, know when to call it a day.