There’s a word for it called ‘Double Entendre.’ But you can also call it sarcasm.
People who do this facetiously are being sarcastic. They could also be treating a serious subject in a lighthearted and funny way.