Term for derogatory words that are only "offensive from the outside"
Solution 1:
I think these are called "reclaimed words" or "reappropriated words":
Reappropriation or reclamation is the cultural process by which a group reclaims terms or artifacts that were previously used in a way disparaging of that group.
(https://en.wikipedia.org/wiki/Reappropriation)
Solution 2:
This is often the case for derogatory terms - they are co-opted by the groups and thereby defused within the group. From searching, I don't think there is a different term for the derogatory words themselves, but the process of using those terms within the group is variously known as co-opting, owning, or defusing in the examples I can find.