You will need to do it on the server; I don't see a way in Mail to tell the app to process fewer folders. If all else fails, you can just delete unused folders on the server (after backing them up somewhere else in a sort of manual archival process).
That's probably not at all helpful for most people using public or company mail servers. I was able to discover this only because I run my own IMAP server. While the Mail app was displaying "Checking mail" for 30 seconds or longer, the server was busily reading (at the app's direction) the full text of every IMAP folder accessible to it. It's probably some immaturely designed feature that's driving those requests -- maybe predictive filing of mail in folders (that is, the Mail app's ability to suggest what folder to save a piece of mail), or something along those lines, but there should at least be a way to turn that off, particularly for people with lots of mail. A full-featured email app would let you ignore certain folders on the server entirely, as you're requesting; many of the third-party mail apps are configurable in that way.
I can confirm, though, that this fix does seem to totally address the problem for me. Showing the Mail app 2.5 GB of mail instead of 40 GB of mail fully solved the problem (as the server's able to process 2.5 GB of mail in a second or two, rather than 30 or 40).
It's not just Apple, of course, but I see more and more of these sloppily designed features, as if the people who are creating them have little perspective and little experience considering the variety of real-world use cases that they're trying to address. Windows, of course, has many similar problems today. Very little seems like a mature, well-tested software product anymore.