All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
It is more appropriate that you do not sleep with your friend in the same bed if there is no necessity for that. In case there is a necessity for him to sleep with you, then this is permissible provided that there is no temptation as the scholars stated that it is permissible for two men or two women to sleep in one bed provided that their ‘Awrahs (plural of 'Awrah, i.e. parts of the body that must be covered in Islam) are covered in a way that they would be secure from touching what is forbidden.
Allaah Knows best.