Basically, a formal greeting is a clear, properly-constructed sentence and uses the full words. "Hi" is short for "hello", so that's informal. Avoid shortening words, and avoid slang of course.
Informal: Hi, I'm Amir. How're you?
Formal: Hello, my name is Amir. How do you do?
Some examples of formal greetings:
How do you do? (This is just a polite greeting; reply with the same sentence)
How are you doing? (Also polite, but this is a question.)
Good morning / Good day / Good evening.
It's a pleasure to meet you. (first meeting)
It's a pleasure to see you again. (if you already know them)