I may have finally found something that works reliably. At least it's been a couple of days without Mail pegging CPU usage at 100%+. If you have multiple email accounts it's a bit tedious, because you have to make the changes separately for every account, but...
The whole of the solution: In Mail.app's Preferences..., click on Accounts, and then for each account on the left, turn off "Store junk messages on server" and turn off "Store deleted messages on server".
This means you won't be able to see mail you mark as Junk or that you delete on one machine on any other machine, but that's probably acceptable for most people. It certainly is for me. While I was at it I also set "Delete junk messages when:" to "One month old", so spam messages wouldn't stick around and clutter my Mac.
This also had the effect of removing a piece of "zombie spam"... A message in the Junk mailbox that kept coming back no matter how many times I deleted it. I know other people who've had this problem. I wonder if the problems are even related... Messages keep getting deleted and reinstated and a fresh search or some kind of reindexing takes place with each state change, or something like that.
In any event, my Mac has been running a lot cooler, for a couple of days now. I highly recommend giving this a try, if your CPU is still pegged or you're experiencing zombie spam.