I just learnt that 「名前は何ですか。」 sounds non-native.
What would sound more natural?
Let's say I am addressing a friend of a friend, same age, after a futsal game where we talked together without being formally introduced.
Just to add to Tokyo Nagoya's answer, I thought it'd be useful to mention that "名前は何ですか" is perfectly grammatical, and the reason that it can sound non-native is cultural.
Japanese tend to avoid questions that are too direct. Especially, the 何 can sound a bit direct or crude.
One way to get around this is to ask in a different way, as Tokyo Nagoya suggests. Note that all his suggestions avoid using 何.
Also note that Japanese people will (in general, not all situations) feel less of a need to know your name than would be the case in many western cultures. You could be called 先生、お兄さん、おじちゃん、彼、旦那さん (if you're a guy) depending on your age, your status and the situation.
It's also not uncommon that someone will ask your friend or partner for your name in front of you (to avoid asking you directly). This might seem borderline rude in some western cultures, where people might prefer to be asked directly.