$2 is the proposed new name, it still does not exist under this name so it cannot be queried for gender. Both names refer to the same user currently named $1, who has the gender settings (these user settings will be applied later to the new name once it is applied; then $1 will no longer have its own settings, it may be deleted/hidden, or kept as a public redirect (possibly protected against deletion or modification of its user pages and talk pages). So this is the same gender of $1 which would apply to both names.
Note that the gender may be needed only in a few language for grammatical forms. If a translation does not need it, the GENDER marker must still be present but may containt empty text (in the English text, the text is the visible user name, not the gender itself, and there's no alternate gender variant of that name and no need to add any other personal gender particle which may be required in addition to the specific user names (I think these gender particles are needed only in some native African languages; in some Slavic languages, there are sometimes variations of user names depending on case on specific constructs, which are also dependant on gender).