I'm sharing this solution because during my research all the recommended solutions would require me to have a Windows device to regenerate the certificate.
My printer was available on macOS's Printers, but when I tried to print it wouldn't work, and when I opened the printer queue a message saying that the certificate was expired was being displayed.
The printer used to work on the older macOS versions, however after the macOS 14 upgrade it stopped working.
This solution has been tested on macOS Sequoia 15.1.