It's possible to book a hotel during your layover if you have a long layover and the transit country or district allows transit passengers to leave the airport without a visa. Check with your airline or the immigration authorities of the transit country or district to determine if this is allowed and any visa requirements.