So long as the cost (fines, legal fees, lost revenue due to bad press) is less than the increase in revenue they receive from forcing users to buy their overprices cartridges, HP's behavior won't change.
My most recent printer is an HP I bought at Costco because I knew it worked with CUPS and HPLIP on Linux and macOS. Given how many times I've seen HP pull this stunt though, I'll most likely shop for a different brand next time.
Part of this is also that HP has captured a LOT of corporate printing locations. The cost of migration for those businesses, universities and organizations is huge. I think that is why they keep getting away with this. Even if individual consumers move away from HP, they still own a huge chunk of the corporate printing market.