Opening the book…
Humour sets the temperature of a room faster than anything else you do. A joke at your own expense tells everyone that mistakes are survivable here; a joke at someone else's expense tells them the same thing in reverse. The second kind is easier and gets a bigger laugh, which is exactly why it needs a rule.
When a joke arrives, check who pays for it before you say it. Aim at your own vanity, your own failures, your own absurdity. If you are the most senior person present, assume any joke about someone below you lands three times harder than you intended.
Affectionate teasing between equals who both give and take it is a different thing entirely — but you have to have earned it, and you have to be willing to receive it. Never punch at someone who cannot punch back.