This error happens because updating your Mac often removes a background program called Rosetta, which acts as a translator so your Mac can talk to older printer software.
To bring that translator back, go to Finder > Applications > Utilities > Terminal. When the Terminal window opens, copy and paste softwareupdate --install-rosetta --agree-to-license into the window and press Return on your keyboard. That single command installs Rosetta so your Mac can understand older printer software again.
Next, go to System Settings > Printers & Scanners. Hold down the Control key on your keyboard, click inside the printer list box, select Reset Printing System, and confirm. Unplug the USB cable from your printer, wait ten seconds, and plug it back in.
Now go to System Settings > Printers & Scanners > Add Printer, Scanner, or Fax and select your HP LaserJet 1022 from the list. In the Use menu near the bottom, select Generic PCL Printer. Using Generic PCL lets your Mac send print jobs cleanly without relying on outdated HP software. Restart your iMac when you are done, and your printer should work normally.