In vanilla Skyrim, there is a well-known bug involving Morthal Guardhouse. Legate Taurinus Duilis is unable to enter the Guardhouse to sleep, since it is always getting locked at night. Unofficial Patch tried to fix this by adding an unused Morthal Guardhouse key into the game. However, it required giving the said key not only to Taurinus, but also to Benor and Stormcloak commander Arrald Frozen-Heart.
However, I've found out that all the other guard barracks in Skyrim are never ever locked. I think that the Morthal Guardhouse wasn't supposed to be locked either, especially since it is marked as a public area.
In Dawnstar, Legate/Stormcloak commander also has to sleep in the city's barracks and not in Jarl's Longhouse. However, since the barracks are always open, he is able to reach his bed without any issues.