Pregnant women are generally advised to avoid medications, including sleep aids, during pregnancy. There are both prescription and over-the-counter medicines. However, as there are no studies or research on its long-term effects, you should avoid taking melatonin over a long period of time during pregnancy. First off, your growing belly can make sleeping positions uncomfortable.
The risk of a malformation is limited to the first trimester, when lip and palate formation takes place. Therefore, benzodiazepines, when used later in pregnancy, do not carry this tertogenic risk. There have been a few studies on melatonin during pregnancy, but most have been done on animals and the results are contradictory.