Solution 1:

The easiest way to answer this question is to start by replacing the pronoun him or her with the referent that the pronoun points to. Thus, in the case of

If my daughter [had been] born a boy, I would have named her Harry.

swap out her in favor of my daughter:

If my daughter [had been] born a boy, I would have named my daughter Harry.

and in the case of

If my daughter [had been] born a boy, I would have named him Harry.

swap out him in favor of the boy:

If my daughter [had been] born a boy, I would have named the boy Harry.

Now ask yourself which of the two pronounless sentences expresses the idea that you originally had in mind and were trying to express. Once you've answered that question, swap the appropriate pronoun back in place of "my daughter" or "the boy" (as the case may be). Voilà: you have the right pronoun in place to express your original idea.