Even though the act of shouting it in itself wasn't illegal, it was still not nice and disrespectful given the circumstances, hence why it was incorporated into the punishment. I am struggling to think of a nice "unusual punishment" in this traffic violation scenario that wouldn't incorporate the yelling part, but I guess I am not as creative as this judge.
https://reason.com/2019/01/04/co-man-wins-175k-for-police-si...
> In July 2016, Joshua Condiotti-Wade of Colorado participated in a public protest with signs that said "Fuck Bad Cops" and "Blue Lives Murder." Commerce City police officer Chris Dickey approached him, accusing him of trespassing and disorderly conduct. [...] > Condiotti-Wade has now received $175,000 in compensation from the city."
https://qz.com/890689/what-us-protestors-can-and-cannot-do-a...
If nobody is there, nothing is being disturbed.