Depends. Some people will say "21 Uhr", some people will say "9 Uhr", one isn't more formal than the other.
Of course with the 12h format you always need additional context to know if you mean in the moring or in the evening, since we don't use "am/pm".