The ruling marks another victory for the U.S. Department of Justice, which has sued more than a dozen states over similar policies.