It is "legal" in the sense that no law prevents moonlighting like this. However, iif t is against either the officer's union contract or against his/her police force's rules, he or she can't do this: employment (including union) contracts may restrict the right to other or secondary, etc. employment, and an employer, including a police force, can put out rules about whether (and, if so, in what capacities) their employees can work at other jobs or businesses.