This is called satire.
There are other terms for putting words in people’s mouths that they never said.