Hi,
Information about the exact HP printer model would help.
Is it an AirPrint-enabled printer connected to the same Wi-Fi router as the computer? If so, you may want to try the following procedure, in this order and with these waiting times:
Power off the Wi-Fi router, the printer, the Mac, and all other devices/computers. Wait two to three minutes. Power on the router. Wait two to three minutes. Power on the printer. Wait a minute or two. Power on the Mac. Finally, power on all other devices/computers.
Please confirm that you are using a MacBook Pro running macOS 11.7 Big Sur (in your profile), since this has been posted in the High Sierra community.