Is there a word for when a derogatory title or form of address is used affectionately?

For example, ***nigger*** is highly offensive, but some friends address each other with that word.

Perhaps I'm thinking of a specific type ***euphemism***.