The legal answer is “whoever signs the birth certificate.” There isn’t a specific statute addressing this or a huge backlog of case law. It’s just how the process goes: (1) baby is born, (2) birth certificate is created based on input the nurse receives from the parents, (3) birth certificate becomes legal when reviewed and signed by one of the parents. So if one parent or the other isn’t present for the signing, the one who is there could legally make any last minute changes to the name that they want.
There is a process for changing errors after the fact, but it requires a judge to sign off on the new information. If the parents come to some sort of agreement in the meantime, this process usually goes pretty smoothly. But if their disagreement is still intractable by the time they get to court, then the judge has to decide which parent has the better case. I’ve never seen one of these cases in person, but I imagine it involves a lot of sighs and rolling of eyes on the part of the judge.