Lawmakers in more than 20 states this year have filed legislation targeting so-called sanctuary policies that limit cooperation with federal immigration authorities.