Well, it surely is not formal, but it's not rude. It could be "Jak pan ma na imię", although somehow I think I'd ask a stranger for a full name and ask "Jak się pan nazywa?".
"Jak ma na imię?" doesn't work here, it would be a question about some 3rd person singular subject that must be known from the context.
The preposition "na" can mean "for" and take accusative . We learnt it once before with the expression na sniadanie (for breakfast).For example "co jesz na sniadanie?" what are you eating for breakfast. In this example, the literal translation is " what do you have for a name?" and na takes accusative .