The Support Article What to do before selling or giving away your Mac offers a step-by-step process on decommissioning a Mac without creating syncing issues with iCloud.
Important: Do not manually delete contacts, calendars, reminders, documents, photo streams, or any other iCloud data while signed in to your iCloud account. Doing so will not only delete that information from your Mac, but will also delete it from the iCloud servers and any other devices you also sync with iCloud. Instead, follow the steps below to remove your iCloud account from your Mac and leave your iCloud data intact on your other devices.
This would not be a good thing, since one of the following steps is to reformat your drive.
Interestingly, the article lets you put the Mac into the state that a new user would find when opening up a new Mac for the first time. After formatting the drive and reinstalling a flavor of Lion OS X (Lion and Mountain Lion), Setup Assistant will automatically start up and show the Welcome screen. Instead of selecting a country or region, you click Command-Q, which will shut down the Mac — Go figure!
The next time the Mac is started, it will launch into Setup Assistant.