What is it called when you take a word with a bad connotation and make it a word with a positive connotation?

Solution 1:

One term is melioration

Historical Linguistics. semantic change in a word to a more approved or more respectable meaning. https://www.dictionary.com/browse/melioration