The justices’ decision, not expected for several months, could affect similar laws enacted by another 25 states and a range of other efforts to regulate the lives of transgender people, including which sports competitions they can join and which bathrooms they can use.