The ruling also effectively barred federal prosecutors from using key pieces of evidence as they continue to investigate whether Mr. Trump illegally retained national defense documents at his estate.