What is the legal term for claiming someone said something they never actually did, basically, putting words in their mouth? Is it called libel? Is it some other legal term? Or is there no legal term for that?
The word for a false statement of fact that is used most often is a "misrepresentation" or "false representation of fact" or more generally, an inaccurate quotation.
A statement is a libel only if it damages the reputation of the person about whom one makes a misrepresentation and is communicated in writing to a third-party.
Making a false statement of fact about what someone said to the person who said it is frequently a form of "gaslighting."
In UK law, there are two forms of 'defamation*'; libel and slander. It's only libel if it's defamatory, untrue and likely to last as a permanent record.
Many people assume that it's libel if written but slander if oral. This is not strictly true, it's the 'permanence' that decides the difference.
For instance, a video interview or speech recorded and broadcast nationally or internationally would be considered a permanent record. A whisper in the hallway to a colleague wouldn't.
There's a fuller explanation at NetLawman: Defamation - the difference between libel and slander
*Defamation can be categorised as "a loss of reputation caused by false statements made about a person or a business."