No, for the most part the game is working as intended with the yellow flags, sometimes it'll bug out and penalize you for passing somebody who's spun out - but more often than not these 5 second penalties are during much harder to understand (from an AI perspective) situations.
Example 1, like the video.
Somebody is off track for whatever reason (or ghosted for going very slow), another totally unrelated car is going unusually slow due to whatever (tangled with another driver, maybe bumped the wall), the game cannot recognize that it is not realistic to expect you to slow way down to the slow drivers speed just because he/she happened to make a small mistake while in the presence of a yellow flag.
Example 2, more common
There is a large multi-car wreck (think the final chicane at Dragons Trail), 2-3 cars are ghosted and spinning out, but 1 other car who was also involved in the wreck happened to just hit the wall hard and lose a lot of speed, but hasn't spun out or ghosted. The game doesn't understand that this driver, who's going less than half the speed they should be, was part of the wreck and therefor shouldn't be protected by the no passing during yellow flag rule. If any other drivers get through the wreck without incident, they will likely be penalized for passing the slow car that isn't spinning out.
That being said, more often than not you won't get a penalty for passing wrecked cars during yellow as this seems to not happen every time.
It's a fairly rare occurrence.
Unfortunately it can be race ruining for some people and is definitely not working as intended.
Personally I don't understand why they had to implement yellow flags, all it has done is make things more confusing.