If a child is not old enough or mature enough to understand, remember, and potentially repeat what he’s heard in the confessional, I don’t see a problem with it in the case of an emergency. I can only say though that it would be better to find a babysitter, particularly because it is hard to determine when a vocal child is old enough to understand, remember, and repeat what he hears. (Toddlers, especially as they get into the upper preschool years, have an uncanny ability to remember and mimic what they hear, but little capacity to self-censor themselves or understand why they should.) In any case, the priest should know of the arrangement before you confess and should give his permission for the arrangement.
Possible alternative ways to find babysitters during confession: If you know any of your fellow parishioners in the confessional line well enough to ask them to watch your toddler for a few minutes while you confess, you can do that. If not, you could arrange beforehand with a Catholic friend to go to confession at the same time and have the friend watch your child while you confess. Or, if there’s a moms’ group in the parish, you might suggest that the group set up a babysitting co-op for confessional times at the parish.