How do you have this printer connected: USB directly to your laptop, or either by wired or wireless to your local network?
FWIW. This printer is also AirPrint-enabled. The one thing I find interesting is that the HP Support specifications for this printer, only shows support for up to OS X Sierra (10.12). However, I have an older, but similar HP model, and I'm not having any issues printing to it from my Mac running macOS Sonoma.
One additional thing you can try is to factory default reset this printer to see if that resolves this issue. Check with your printer's User Guide on how to do this. Hint: See page 136 in the guide.