No. If the game is aware it is running on PS5 hardware, by definition it means it was compiled on the PS5 SDK, has the PS5 ID and has been compiled as a specific PS5 binary.
If it was compiled through the PS4 SDK it is a PS4/Pro game, it's compiled as a PS4 binary. A PS4 binary cannot have any awareness that it's running on PS5 hardware.
There are two frames of reference to consider that I think you might be getting confused about:
- The hardware
- The application (i.e. game)
In any of the BC modes the hardware decides based on the software instruction which of the three BC modes to run the software in. Whereas, from the application's perspective, it thinks it's running on PS4 hardware, running in whatever select performance profile based on the hardware ID (which is the only unique info. about the hardware the application sees or knows about the hardware).
E.g. a patched PS4 game compiled as a PS4 binary can never access RDNA2 specific GPU features like Wave32 instructions. It can, however, run at full CPU or GPU clocks, but only because the hardware (seeing it as a PS4 binary) selects that specific legacy mode to run the software in.