Legally, it's consensual. Morally, it's an order.
If anyone except a police officer made a similar request, they'd be guilty of brandishing a firearm and any contract (or agreement to have sex) would be invalid. But if you accede to a police officer's "request", when they have a legal right to kill you for any reason during the encounter, it's considered consent.