As with K2, a synthetic form of marijuana that wreaked havoc across the city this summer, producers of fentanyl and its analogues can sometimes avoid prosecution by tweaking the chemical recipe of the drug to work around specific provisions of the law.