How do I generate a custom invoice ID
I have temporarily solved it by making a change to the core CRM_Contribute_Form_Task_Invoice to use my function for invoice generation if the class I use can be found. Temporary fix for the customer with their current version.

What I am planning on doing as a core PR is taking out the invoiceId generation in CRM_Contribute_Form_Task_Invoice and replace it with an API call: Invoice Generate. That means anyone who wants to customize it can use the apiWrapper hook to do so. Does that make sense?