If your child understands his habit is "not okay" with family, friends & teachers, but persists, he may need evaluation for anxiety
Substitute a "fidget" (wiki sticks or worry stone). Team with his teacher to use a cue like "quiet hands" in a low, calm voice. Chastising him reinforces the behavior. Let him practice "quiet hands" a few min./day, so he can earn tokens for rewards.