Is it allowed for two boys (friends or brothers) to sleep together on the same bed under the same blanket?

If they are appropriately dressed and there is no concern that they would do anything inappropriate then it’s permissible. The hadiths we have condemn two people from sleeping under the same blanket while being naked.