First of all, in both situations Dill is the one innocent child who does not have the stomach to accept cruelty to innocent victims. In chapter 1, Lee writes:
Dill said striking a match under a turtle was hateful.
In chapters 19-20, Dill has to leave the courtroom because the way that Mr. Gilmer treats Tom Robinson makes Dill physically sick. Dill plays an important role in demonstrating that man's goodness might be inherent and given to us at birth because he is closer to that time of innocence than everyone else except Scout.
Another parallel is the function of heat. Jem had suggested the one way to get the innocent turtle out of the protection of his shell was to heat his shell with a match. The trial ironically occurs on the hottest day possible. Everyone is sweating, even Atticus. This trial squeezes the town and begins to get them to move. Because Atticus convinces at least one person on the jury to really think about this, we have hope that race relations will begin to improve. But no one changes without difficulty. Often heat is a symbol used to prove that change hurts, but the heat often molds us into a newer and better version of ourselves. I hope that's what it did for Maycomb.