BEIJING—The detention and televised confession of political crimes by a Swedish activist in China has sent chills through communities of foreigners that engage in civic issues in the country.

Beijing’s public shaming of Peter Dahlin is a sign that China’s leaders may now be trying to muzzle international critics with the same tactics they’ve deployed against local dissidents, say activists, lawyers and academics.

In...