unless the G5 uses a different connector for the cdrom/DVDrom then a G2 type will fit you may however have to swap the front bezel off of your tray onto the replacement as many laptops use custom front faceplates for the optical bay
yep, just checked and the front bezel is a custom faceplate on the G2/G5 models however the interface is a standard Mini SATA
so any low profile (9mm) adapter will work all that is required is to swap the faceplate from your current optical drive onto the replacement carrier changing these faceplates is not that hard as long as you read up on the proper way to remove the faceplate, most have 3 or 4 mounting clips that need to be pressed out (google how to do this)
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".