Yes you can and should wear your retainer at night while you're sleeping.
You shouldn't remove your retainer when sleeping because it will mess with the effectiveness of the retainer.
When you first start wearing a retainer for your teeth you will generally be wearing the retainer 24 hours per day 7 days per week which means even through the night.
Most people will continue to wear their retainers for up to a year while some people may want to keep wearing the retainer at least at night to keep there teeth where they should be.
Your dentist should let you know when you can stop wearing the retainer at night but my dentist told me that I should keep the retainer in at night because if I removed it at night in the beginning it would mess up the teeth and the reason I got the retainer in the first place.