I wouldn't call 嗨 onomatopoeic, since it doesn't seem to be imitating any particular sound.
According to the Ministry of Education's 國語辭典, 嗨 is an interjection that expresses discouragement, regret, surprise, etc. It is sometimes written as 咳, (in this sense also read hai, not ke).
This use goes back to Yuan dynasty drama. It can also be used in chanting sort of expressions such as 嗨唷, which is what everyone was yelling when I was on the tug-of-war team. Acc. to 國語辭典, this use can also be found in Yuan dynasty plays.
Unlike some dictionaries, 國語辭典 does specifically mention the use of 嗨 as 音譯 for English Hi. This use must be quite modern. Acc. to the Oxford English Dictionary, the use of 'hi' as 'a word of greeting' (=hello) is primarily North American in origin, apparently late 19th cent. I wouldn't be surprised if 嗨 = Hi, was a post WW2 innovation in Chinese.