Yes, A First Amendment defense would apply. This is no longer a crime.
In Schacht vs. United States, 398 U.S. 58 (1970) the US Supreme Court held the final clause of 10 USC 772(f) unconstitutional on just this ground.
In that case anti-war protesters rehearsed and performed a skit in which soldiers shot and killed a character dressed as a member of the Vietcong, only to discover and proclaim that the character was a pregnant woman. One of them, Daniel Jay Schacht, was
indicted in a United States District Court for violating 18 U.S.C. 702, ... He was tried and convicted by a jury, and on February 29, 1968, he was sentenced to pay a fine of $250 and to serve a six-month prison term, the maximum sentence allowable ...
In the opinion by Justice Black, the Court held;
This clause on its face simply restricts 772 (f)'s authorization to those dramatic portrayals that do not "tend to discredit" the military, but, when this restriction is read together with 18 U.S.C. 702, it becomes clear that Congress has in effect made it a crime for an actor wearing a military uniform to say things during his performance critical of the conduct or policies of the Armed Forces. ...
... it follows that his conviction can be sustained only if he can be punished for speaking out against the role of our Army and our country in Vietnam. Clearly punishment for this reason would be an unconstitutional abridgment of freedom of speech. The final clause of 772 (f), which leaves Americans free to praise the war in Vietnam but can send persons like Schacht to prison for opposing it, cannot survive in a country which has the First Amendment. To preserve the constitutionality of 772 (f) that final clause must be stricken from the section.
In United States vs Hamilton (2012) the US Fourth Circuit Court of Appeals limited 18 U.S.C. § 702 (wearing a military uniform without authorization), and 18 U.S.C. § 704(a) and (d) (wearing military medals and other insignia without authorization).
Hamilton had, among other actions, appeared at a Vietnam Veterans’ Recognition Ceremony in the dress Uniform of a Colonel of US Marines, wearing numerous medals and awards including two Navy Crosses, four Silver Stars, one Bronze Star, and seven Purple Hearts. He had in fact been medically discharged years earlier with less than 1 year of service, after an accident to his hand, with the rank of Private First Class (PFC). He had not been awarded any of the medals or decorations that he wore. (He had previously been apprehended on military bases three times wearing the uniforms of a colonel (once) and a lieutenant general (twice), but was not charged on those occasions.)
The Fourth Circuit wrote:
We observe that the Ninth Circuit applied such a limiting construction to Section 704(a) in United States v. Perelman, holding that the statute created a criminal offense prohibiting the unauthorized wearing of military medals only when the wearer "has an intent to deceive." (658 F.3d at 1137-38) In our view, the imposition of a limiting construction requiring an "intent to deceive" is appropriate with respect to both Sections 702 and 704(a).
Accordingly, we hold that persons violate the insignia statutes if they wear a military uniform without authorization, or wear military medals or imitations of such medals, respectively, only when they do so with the intent to deceive.
The Fourth Circuit went on to hold these provisions constitutional when so limited, and to uphold the convictions under them, quoting Schacht is support of this holding.