According to this article on TV Tropes and this article in The Guardian, the US military will provide facilities to film makers, as well as advice to help them get the details right. However this is on condition that the film portrays the military in a positive light.
There's a catch — a Department of Defense project officer will keep an eagle eye on the script and production phases. If they don't like the portrayal of the military in your film, they will yank the co-operation. This was a major reason for the failure of the TV series Supercarrier. Other movies DoD rejected include Forrest Gump (because the army protagonist was stupid), Mars Attacks! (because everyone was stupid), and Independence Day.
However the First Amendment prohibits the government from making such decisions based on the content of the speech.
The first amendment reads:
Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.
According to this article on Viewpoint Discrimination:
Viewpoint discrimination is a form of content discrimination particularly disfavored by the courts. When the government engages in content discrimination, it is restricting speech on a given subject matter. When it engages in viewpoint discrimination, it is singling out a particular opinion or perspective on that subject matter for treatment unlike that given to other viewpoints.
Later on the article cites a particular case:
In Rosenberger, the Court held that a student religious journal at the University of Virginia was entitled to the same subsidy from student activity funds received by secular student journals. The Court concluded that the university’s policy of withholding the subsidy from student religious journals was a form of viewpoint discrimination: "[T]he University does not exclude religion as a subject matter but selects for disfavored treatment those student journalistic efforts with religious editorial viewpoints..."
The DOD behaviour would seem precisely parallel to that of the University of Virginia in Rosenberger, in that it does not exclude criticism of the military as a subject matter but selects for disfavored treatment those films with critical viewpoints.
How is the selection of movies for support by the DOD not a form of viewpoint discrimination?
Edit: Government Speech Doctrine
A couple of responses have raised the government speech doctrine. This allows the government to make statements that are not content-neutral, and to pay others to do the same. The doctrine was first defined in a case where government subsidies for medical clinics included a condition that the clinics not provide advice about abortion. The Supreme Court held that since the government was paying for the doctors to give advice it could require them to say or not say anything it wanted. However this would seem to be in clear contradiction with the Rosenberger case mentioned above, where the government (through the University of Virginia) was prohibited from putting a viewpoint condition on its subsidies to student journals.
In Matal vs Tam the Supreme Court followed a three-part test to determine if a particular instance of speech is by the government or not:
Does the medium have a history of use to convey messages by the government? In the case of popular films where the government is not clearly identified as the maker this would seem to be false. The customary "the producers would like to thank..." at the end of the credits is insufficient to override this.
Does the government maintain direct control over the messages conveyed? This is a grey area; the Guardian article above seems to show the DOD having veto power over aspects of the scripts, but paradoxically the fact that the film makers could always choose to walk away and make the film without government help seems to suggest that this control is only indirect. "Direct control" would mean the DOD themselves writing a script and then hiring film makers and actors to produce it.
Does the public closely identify the message with the government? Again this would seem to be false. People go to a film to see a good story, not to listen to government propaganda, and the films in question do not advertise themselves as presenting the government point of view.
So the claim that a film which receives DOD assistance is thereby deemed to have been made by the government does not seem to stack up. At the very least it would be a significant expansion of the government speech doctrine.