If you have trouble sleeping, then by all means meditate when you’re lying in bed, for meditation is a useful substitute for sleep.
"If you have trouble sleeping, then by all means meditate when you’re lying in bed, for meditation is a useful substitute for sleep. Often it can be more refreshing than sleep, for it can dissolve bodily and mental tensions better than sleeping can. It can also calm you down enough so that worries don’t sap your energy or keep you awake. But make sure that you also set aside another time of the day to meditate too, so that you don’t always associate meditation with sleep. You want to develop it as an exercise in staying alert." ~ Thanissaro Bhikkhu "With Each & Every Breath: A Guide to Meditation"