Summary:
Most melee and ranged units can fortify. Non-military, mounted, naval, armored, and air units cannot fortify. These latter units can "Sleep," which means that they will remain inactive until attacked or you manually activate them, but they do not receive the defensive bonus.