MADRID—The Spanish government’s efforts to stop Catalans from voting Sunday in a referendum on independence are testing the loyalties of one of the region’s staunchest institutions: its police force.

Catalonia’s 17,000-strong Mossos d’Esquadra will be on the front lines Sunday when pro-independence leaders plan to stage a referendum on whether the northeast region should secede from Spain.

The...