JPEG (or JIF-based formats, like JFIF or Exif) typically contain:
- Exif metadata (which is a TIFF structure), can only be uncompressed (except for the embedded thumbnail which can be JPEG-compressed), as per TIFF 6.0 spec
- XMP metadata (as a UTF-serialized XML document), could probably be compressed, but it's not according to the XMP spec.
- COM markers, plain text only
- JFXX extension, which can hold a JPEG-compressed thumbnail, of limited use
- ICC_PROFILE (ICC Profile) uncompressed only (as per ICC spec)
- Adobe Photoshop IRBs, uncompressed (as per Phothoshop format spec).
PNG typically contain:
- tEXt, iTXt and zTXt chunks. The zTXt chunk is compressed using zLib (same as the PNG pixel data), and iTXt can be compressed as well.
- XMP in PNG is defined to use the iTXt chunk type, but the spec only mentions uncompressed (as per XMP spec). You may be able to compress this, but I'm not sure if it's really allowed.
- iCCP (ICC Profile) uncompressed only (as per ICC spec)
In other words, yes, you could compress it, but most of the time, the data would no longer be readable by software written to follow the mentioned specifications. Thus, it's not really practical.