While the lawsuit’s goals were “laudable,” the judge said, it ran afoul of First Amendment protections.