It’s not so old. Both Green’s Dictionary of Slang and HDAS have citations as late as the early 1990s.
It’s not simply sleeping on the job, but finding an out of the way place where a cop could rest undisturbed. The first citation in Green’s:
1933 (con. 1900s) C.W. Willemse Cop Remembers 137: I’m not telling this to prove the merits of ‘cooping,’ but it has its good as well as its bad aspects. […] under the two platoon system it was almost impossible in a busy precinct to get a moment’s relaxation while on reserve. The Station Houses were noisy, filthy, vermin-ridden and foul and a clean bed somewhere on post was preferable to a bed behind the green lights.
Coop has also been used as a noun to mean a place where a policeman could hide and rest since at least 1931.
It’s ultimately from the noun meaning a pen for poultry, but it comes into police lingo by a longer route. Coop has been underworld slang for a prison or jail since the late-eighteenth century. The verb also meant to hide from police or other criminals, from at least 1877. From there it jumped to police with a slight change in meaning.