Just as a point of clarity: Apple's download page has wrong info on it, making things only more confusing. It says "Not compatible with macOS v12 and newer." That ain't true. The web page itself says it was last updated in 2020, and it was true then. But the download itself was updated in 2021 to allow installation past Big Sur. So, the download page should actually say "Not compatible with macOS v15 and newer." I submitted a correction, we'll see if anyone reads it.
Mucking things up further, there's actually a bug in the Distribution file -- Apple's clearly intending it to allow installation on anything before 15.0, but the script actually allows 15.0.0. So, I guess if you're really desperate and can't get the install working, you could back up your stuff, roll your Mac back to 15.0.0 (you can use MIST to download it), install, update, and then migrate your stuff back.
(Even more bewildering is that the meta tag in the page source, which shows up in Google searches, says "HP 5.1.1 Printer Software Update can be installed on macOS Monterey"...which, apart from being out of date, directly contradicts what the page itself says.)
I have no need to block my installer from installing on whatever comes after Sequoia, so I just decided to let it install what through macOS 19.x.x:
sed -i '' 's/15.0/20.0/' ~/Downloads/hp-expand/Distribution
Thanks for posting the script (which I originally discovered on the MacRumors site linked above). It got my mother in law's 26 year old HP LaserJet 4000N printing on her new MacBook Air M3 -- her first Mac after switching from Windows! The printer was so old that I had to set a static IP on it and tell macOS to find it that way. Life being the ironic thing it is, something mechanical broke on the beast the next day, and now she's gonna dump it, since they have a second, newer HP laser printer anyway. Which, by the way, works fine with AirPrint.