PUYANG, China—One night this September, construction supervisor Chen Shouli fired off a joke in a chat group.

“Haha,” he typed on his black iPhone 7, followed by an off-color wisecrack about a rumored love triangle involving a celebrity and one of China’s most senior government officials.

Four days later, he says, the police telephoned, ordering...