Didn't notice the visibility of Jenkins#trimLabels() -- But when it's about use in script, Groovy's rules are weird anyway.
My other suggestion to use Label.reset() works however: Jenkins#trimLabels() is mostly the same as `Jenkins.instance.labels.each { it.reset() }`, which works for me from Script Console. More targeted resetting can be done by checking whether the label you're processing is one of the labels affected by your rules.