I think that the most accurate term for borrowing and changing a quotation is adapting (along with the verb adapt and the noun adaptation). In the example that the OP gives, "Nerd and proud!" echoes but fundamentally alters the predecessor expression that the poster identifies as "Mutant and proud!" from X-Men.
It's somewhat instructive to consider that "Mutant and proud" may itself be lifted and adapted from a hit song from 1968 by James Brown: "Say It Loud—I'm Black and I'm Proud." According to IMDb, "Mutant and proud" goes back to dialogue spoken several times in X-Men: First Class, including this instance by Raven Darkholme (2011):
Raven Darkholme: And one more thing. BEAST!
[Raven places free her hand on her chest]
Raven Darkholme: Mutant and Proud!
whereas Jams Brown's exhortation has been percolating in U.S. culture for almost fifty years. Altered wordings of this type are quite common—so much so that the introductory phrase "With apologies to [the person responsible for the original quote]" preceding the adapted wording has become a cliché acknowledgment of the expropriation, as here in Nathan Rosenberg, Perspectives on Technology (1976), in which the author takes liberties with Georges Clemenceau's famous remark that modern war (in the early twentieth century) had become too important a subject to be left to the generals:
With apologies to Clemenceau it might be said that if technological change is not too important a subject to be left to the economist, it certainly is too diverse a subject to be left to the economist who refuses to step across narrow disciplinary boundaries.
This quotation also shows the worst thing about such adaptations: the original crisp, striking wording too often turns to mush in the rephrased version, making an apology entirely appropriate.