You can say 안녕히 주무세요 to people much older than you, like your parents or your teachers. 잘 자요 is the most safe greeting. I mean, it will not be very impolite no matter who you say it to.
좋은 꿈 꾸세요. [Informal] 좋은 꿈 꿔. [Between close friends]
잘 자, 내 꿈 꿔 ▶ Good night, dream about me.
It's said between close same-sex friends(usually girls) or couples. If a guy is your close friend, you could say it a bit of fun. Remember 잘 자요 as a general night greeting ;)