The correct sentence showing proper capitalization is:
The District Attorney was upset when Judge Morales dismissed the case.
In this sentence, "District Attorney" is capitalized because it is a formal title, and "Judge" is also capitalized as it is used as a title before the person's name.