I might be selling my iMac computer, and I know I have some CD's it came with.
Is it possible to format the drive and bring it back to how it was when it was new? (using those disks)
It sure is.
Alternatively, you can access the Disk Utility application while you're in the installer. You can use Disk Utility to erase and repartition the drive (this will take longer, but it means you can be reasonably sure the new owner wont' get your information).
When you repartition the drive:
Let me know if you need more information.