So, you want to use the iMac G5's screen as the second display, correct, not the MacBook Pro?
The iMac's video port is for output only. There is no traditional way to connect it to another computer directly, for the other computer to use the iMac's display.
However, there is a way to do it over a network connection, using this clever application
and the "VNC" protocol. You're essentially doing screen sharing, but making the MacBook Pro send its "second screen" (which the app creates) to the iMac, which displays it at full screen using VNC.
The main limitation is network speed, so you should use a wired Ethernet connection instead of wireless, between the two Macs, if possible. Even then, it will not be as fast (screen refresh rate) as a "real" display connection, but it should work reasonably well for mostly static images (versus something that is always moving like video editing or playing games).
But getting a regular display that connects in the normal way would be much simpler and more convenient.