Hello @Neeraj and welcome to the Community :),
Do not leave unused pin floating. You can connect these unused pins to ground or to supply on the PCB, or use PU / PD.
The unused I/O pins should be configured as analog input by software; they should also be connected to a
fixed logic level 0 or 1 by an external or internal pull-up or pull-down.
For more explanation I advise you to refer to Getting started with STM32G4 Series hardware development boards application note.
As already mentioned by @KnarfB the AN4899 Application note" STM32 microcontroller GPIO hardware settings and low-power consumption" can help you and precisely Avoid floating unused pin section.
I hope this help you!
Kaouthar