Castor Oil is a natural remedy for regrowing hair and making your hair much healthier.
And yes you can sleep with the castor oil in your hair to help promote hair growth and prevent future hair loss.
I would recommend wearing a shower cap during the night when leaving castor oil in your hair to prevent the castor oil getting onto your pillows or sheets.
Then in the morning you can wash the castor oil out of your hair and then add some more castor oil to your hair again before going to bed.
I've slept with castor oil in my hair before and just wore a shower cap at night and my hair did grow much thicker and I stopped losing hair.