Judges in more than a dozen cases have cited social media posts by President Trump and members of his administration in decisions against the government.