Generally and legally no, since the installer on the DVD is checking for machine specific model identifier for the MacBook Pro that the DVD came with as shown in this workaround .
Once the file is opened, scroll down about ¾ of a page and you will come across a series of strings named hwbeSupportedMachines.
Now, technically the DVD's that came with Macs included a standard Mac OS 10.x.x Install plus new drivers for hardware specific features for that new model, stuff that would not be known about or included in the 10.x retail install DVD Mac OS X versions (builds) for computers. Which means the OS that came with your Macbook Pro once its installed on the Mac Book Pro should include all it needs to run on the iMac too. You just have to get it there, which you could do via cloning a 10.6 install from the MacBook Pro to the iMac or maybe via installing OS X 10.6 on the iMac via the MacBook Pro using FireWire target disk mode.
Untested Solution if you want go the Upgrade path of 10.5 to 10.8 wihout erasing the iMac
Backup important Data on iMac
Boot the iMac into target disk mode, by holding down the T key while boot the iMac.
Connect iMac to the MacBook Pro via FireWire
Boot the MacBook Pro from its 10.6 Installer DVD
Try to select for installation of OS x 10.6 the hard drive with 10.5 installed on it in the iMac.
Note: This is the untested part, the Restore / Install DVD may not allow upgrades from prior OS X versions.
Boot up the iMac and then upgrade to latest version of OS X 10.6
Install OS X 10.8
This will promote better performance via a clean install to a blank disk thus reducein legacy cruft and other left-overs from old OS X installs and old Applications, etc.
First thing upgrade the MacBook Pro to Mountain Lion, if you have not done so already.
Next back up all your files you want from the iMac, since OS X Lion / Mountain Lion will not be able to upgrade users from Mac OS X 10.5 to 10.8.