E.g. "geek" or "queer" were originally meant as an insulting term, but were taken by the recipients as titles of pride.
Is there a term for this phenomenon?
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It only takes a minute to sign up.Sign up to join this community
Reappropriation is the word you are looking for.
... the cultural process by which a group reclaims— re-appropriates —terms or artifacts that were previously used in a way disparaging of that group. For example, since the early 1970s, much terminology referring to homosexuality—such as gay and (to a lesser extent) queer and poof—has been reappropriated. [...] A reclaimed or reappropriated word is a word that was at one time a pejorative but has been brought back into acceptable usage—usually starting within the communities that experienced oppression under that word, but sometimes also among the general populace as well. [...] This can have wider implications in the fields of discourse, and has been described in terms of personal or socio political empowerment. [...]
However, the phenomenon is much older, especially in politics and religion. Cavalier is example of a derogatory nickname reappropriated as self-identification, while Roundhead, a Royalists derisory term for the supporters of the Parliamentary cause, is not (it was a punishable offence in the New Model Army to call a fellow soldier a roundhead). Tory (orig. from Middle Irish word for 'pursued man' Tóraidhe ), Whig (from 'whiggamore' (See the Whiggamore Raid)) and 'Suffragette' are other British examples. Yankee was originally used as an insult to America, but was reclaimed in the song "Yankee Doodle".
The phrase "linguistic reclamation" has been used by academics. See "A Queer Revolution: Reconceptualizing the Debate over Linguistic Reclamation" in Colorado Research in Linguistics. http://www.colorado.edu/ling/CRIL/Volume17_Issue1/paper_BRONTSEMA.pdf
Co-opt is the common word for appropriating a derogatory term, especially in sense 3 of the linked definition:
To take or assume for one's own use; appropriate: co-opted the criticism by embracing it.
The words I most often see used to describe this phenomenon have been mentioned in the body of other answers, but not actually suggested as answers!
I'm including some examples found with the help of Google:
The difference seems to be that embrace means accepting the word as it is with its negative meanings whereas reclaim means that the new positive meaning has replaced the older negative meanings to some degree.