The Texas legislation has been championed by the state’s conservative lawmakers, who tout it as a measure to protect privacy and argued that local nondiscrimination ordinances allowed men to use women’s restrooms.