FORT WORTH, Tex.—A federal judge on Monday ruled in favor of 13 states against President Barack Obama’s directive that public schools must allow students and adults to enter whatever bathrooms or showers they choose, a policy imposing transgenderism on the nation’s schools.