Before I answer this I'm going to point something out.
Humans suck at randomness. If I put some of my friends on the spot and ask them for a random number 1-10 I can predict with 95% certainty what number they're going to choose. They're subconsciously biased. Even humans trying their hardest to not be biased fall foul of the mathematics of randomness (see Benfords Law, for example. The distribution of first digits in lists of random numbers is not as simple as you might first assume). If put on the spot and asked to solve the trolley problem a human being will likely choose one option over the other every time. This comes from a complex confluence of their memories, biases, training, emotional state, physical state, etc etc etc... Machines on the other hand are really good at randomness. Even Psuedorandom number generators are good enough that you could use a single stream of numbers generated from a single seed for a lifetime and never start repeating or see a pattern.
The point being: Randomness does not help humans in court. Being able to justify their actions (one way or another) does. Even if it's provable that the driver had time to make a conscious choice a jury would still accept 'I had to pick one or the other' as a defence regardless of why they chose one or the other. If the driver distinctly says something like 'I hate those damn motorcyclists and wish they would all die', that might colour things a bit, but for the most part a group of humans will be able to understand why another human would choose one over the other in the heat of the moment, and they can easily be convinced (even without hard numbers) that it was actually a trolley problem. They don't expect true randomness. They expect reasonable actions.
Now: On to the machine.
Random numbers are already used extensively in machine learning. The reasons why vary from method to method, but randomness is something that comes up a lot. It's easy to think of machine learning as a decision tree (if X>Y, do A. else if Y>Z, do B, else if ...). Often this is the result of a machine learning algorithm (for example the xgboost algorithm produces a decision tree), but for something as complex as driving a car it is guaranteed to Not Be That Simple. The trouble with this is that the more complex the algorithm the less transparent it becomes. Transparency (The ability to inspect the machine learning and understand it's choices) is a difficult thing to achieve. There are many papers on how to manage it in a variety of cases, but sometimes it's just impossible to produce a chain of reasoning a human would find compelling. If the machine learning can produce all the telemetry leading up to the accident it should be (relatively) simple for a human accident investigator to confirm that it was a trolley problem and no non-fatal solution existed. From there it's just a question of why the machine chose one or the other.
We might accept 'There was a 10.9% chance of reduced property damage if the pedestrian was hit'. It's a dispassionate line of reasoning, but at least it's there. What we wouldn't necessarily be able to accept is 'Tree 1 split 3,4,6,7 supports option A, Tree 2 split 1,2,4 supports ... Tree 19785 split 7,2 supports option B. 18567 trees support option A. Option A chosen.' (Pseudo output from a Random Forest decision algorithm). Interpreting such outputs is a job best left to the experts, who can use statistics and machine learning expertise to boil what might be an incredibly complex (and often partially randomly created) line of reasoning down to something humans can understand.
Of course, there's every chance that the actual choice was purely down to the state of the machine learning and no strong chain of logic. The machine has learned from whatever training problems it was given, and that's that. In that case the testimony of an expert saying 'This is just the way the machine learned, but there was no option that saved lives' should be sufficient. There may already be randomness in the machine learning steps. Neural nets (for example) are initialised in random states to allow the optimisation algorithms to work properly, so one Neural net might make a subtly different choice to another. Adding an extra layer of randomness to this choice doesn't help.
Now: As for who would be liable and for what crime: That's a very active area of discussion at the moment. Tesla currently get around it by saying that the human driver should always be attentive and able to prevent accidents. As things get more automated this may change.
But whatever happens with that adding more randomness isn't a solution to the trolley problem. It was an accident. Someone died. No amount of dice rolling will change that.