MEXICO CITY — Mexico’s war on drugs took a grim twist this week, as a prominent mayor said he had created an undercover group of operatives to “clean up” criminal elements — even if it had to act outside the law. Underscoring why the mayor may have felt compelled to take such steps, the new police chief in a neighboring town, a retired brigadier general, was shot and killed Wednesday, four days after taking up his post.