I'm not a doctor. But this definitely is not inherently dangerous. Your body produces melatonin as soon as it's dark.
That said - if you take an overdose of heroin, then ANYTHING that makes you sleep is dangerous, including just being tired lol. By that I mean, if you take an OD of heroin, then when you're awake - you can make sure you're breathing, this is harder if you're not awake.
BUT - unlike benzos for example, that will not only make you tired, but ALSO suppress your breathing - melatonin will just make you tired. It's not going to make the dose of heroin any more dangerous than it already was (or wasn't).
Also - it's an incredibly mild sleep-aid. It's not going to "potentiate" your buzz. It is just (at most) going to make you more tired.