I would argue that traffic law provides the answer. If you can't avoid violating any law, there is a clear sequence defined you should use to decide what law to violate (they're all numbered, TLDR is : violate the larger numbers first).
In traffic law people actually thought about this. First you are to safeguard pedestrians, then cyclists and motorcyclists then cars, then trucks/buses/... and finally yourself. Things like right side of the road, red lights, ... are far down. Things like trains/trams are tricky.
What is not generally understood is that this sequence matters. Most people realize that in order not to block an ambulance, you are not just allowed, but required to run a red light. Less known is that ignoring road safety, to some extent, is legal and required if you're bringing a seriously injured person to the hospital. If you can avoid a collision by crossing to the wrong side of the street, you are required to do that ...
So the legal answer here is simple and well-defined : Assuming you can't move to the other side of the road reasonably safely, you should slam your car into the truck (needless to say, as slowly as possible). You are certainly NOT to take liberties with the safety of pedestrians to avoid hitting a truck.
This is complicated by other laws of course. First you are not expected to do more than a certain "standard" human would do, second in this situation obviously there is a problem of intent when things do go south (did you intend to hit those pedestrians ? What about if you made that choice to avoid the truck ? What if you and the truck both decided to avoid each other and both went for the b). Who is the "root" responsible, and how is the responsibility divided amongst the people who violated the law ? So this makes legal culpability in these sorts of cases a murky area. If you slam your car into a kindergarten to protect yourself, though, I think it's reasonable to expect prison time and a hefty financial problem.
But the answer seems to be : if there is any way to avoid the truck, ignoring all normal traffic laws (but NOT hitting anyone), that's the way to go. If there's not, you hit the truck.