Is it possible? Yes.
Will the benefit outweigh the costs? No.
Without going into a lot of detail, and at the risk of oversimplifying things, in the early days mining bitcoins was easier than it is now. And, as time goes by, it will continue to get harder.
Another contributing factor is that the kinds of calculations needed to mine bitcoins are actually better suited to GPUs instead of CPUs (i.e. a graphics card is better at processing these than a CPU is). So, using your iMac as an example, the best GPU your model shipped with was a Radeon HD 5670 that had 512MB memory and while this may have been okay to mine bitcoins in 2010, it would take so long to do now that the cost of electricity would outweigh the value of any Bitcoin you’d be able to mine (as it now takes a lot longer to mine and the cost of power only goes up).
This brings me to the other factor. There is a real cost in mining bitcoins, starting with the cost of electricity. You’d need to have your Mac working overtime on the calculations 24/7 for literally months to try and obtain a single bitcoin. Trust me, the cost in power will be a lot higher! That is why many bitcoins are now being mined in bitcoin farms in China (i.e. air conditioned buildings with many devices on 24/7).
To my mind, the only way it’d be worth doing on a Mac would be if you were going to have access to one of the new iMac Pros (about to ship in the next couple of days) and it was configured with a Radeon Pro Vega 64 graphics processor with 16GB of HBM2 memory, and you had it running 24/7 at a workplace (i.e. so you’re not paying for the power) and assuming you didn’t have to pay for the iMac Pro itself. But of course that’s not a realistic scenario, and unless your employer was also on board, may risk termination of employment!
Instead, if you want to get into mining, look at a dedicated machine designed for this purpose. Below are some examples:
NOTE: I am not affiliated with any of the products listed above, nor have I any experience with them whatsoever!
As you can see, the above items are not cheap. And, on top of that you need to factor in the cost of running them (i.e. electricity, air conditioning, etc) where you live. So, my advice is forget about using a Mac (or any PC), do your research, and perform the calculations necessary to determine the costs to you and the likely return.
A word on the lottery analogy
As mentioned by various people via the comments below (and those already migrated to chat), many see bitcoin mining as being akin to buying a lottery ticket. While I understand the analogy (i.e. because the odds of success are extremely low, and because someone could mine bitcoins for a whole year with no success while someone else could be successful after only ten minutes), this analogy is actually somewhat misleading.
When someone buys a lottery ticket they essentially end up with a ticket containing random numbers in the hope that those numbers get selected. Now the odds of those numbers getting selected will depend on the lottery you're playing. However, bitcoin miners are not rewarded for essentially doing nothing, because the very act of mining bitcoins is in fact providing a record-keeping service for the overall bitcoin cryptocurrency and payment system. Bitcoin miners (if lucky enough) may get paid (i.e. rewarded) with newly-created bitcoins for this service. Likewise, even the term mining is somewhat misleading. Miners typically produce something, but bitcoin mining doesn't actually produce anything. For more information refer to Bitcoin and Beyond: The Possibilities and Pitfalls of Virtual Currencies.
Nevertheless, using the lottery example is useful to convey that (1) the odds of success are extremely low and, (2) you may get lucky instantly (and therefore the return on investment is excellent) or over the longer-term you'll spend a lot of money for very little gain.