They work interchangeably and neither is formal or informal but there is slight difference in usage.
"Hallå" would more commonly be used to call for someone's attention, answering a call, or trying to get confirmation that someone can hear you, whereas "Hej" is more purely a greeting. They both mean hello, but the difference is more like that between "Hey" and "Hi". Don't worry about it too much.
For example, a phone conversation might start:
Hallå, det är Stefan, Hello, it's Stefan.
Hej, det är Sara här, hur står det till? Hey, it's Sara here, how are you?
Hej Sara, det är bra, hur är det själv? Hi Sara, I'm good, how are you?
Sharing quite a number of words and a bit of the basic grammar, but that's more or less the end of it in modern Swedish. Older Swedish has much more of the German grammar, and also more Germanlike words.
Swedes in general usually don't understand German unless they've learnt it in school (or heard it a lot).