"He knows what to do, but needs more confidence to actually do it."
It takes practice. I'd ask the principal to make sure this happens at school. I've found that when I go in on a bullying issue, my words carry much, much more weight if I go in there with the approach of "these kids need to learn appropriate behavior, my child included" instead of "these kids need to stop bullying my kid." Requesting social support for my child acknowledges the complex nature of these interactions.

It's separate from the bullying, but it would be useful to have a chat with the teacher about his behavior expectations when a sub is there. Either your DS or the sub (or both) must be informed about variable expectations.