Overwrite a class in /include (or format value in ForHistory.php)

Hi,
I would like to implement the proposed fix

Field Due_date has wrong format in subpanel (activity, history) #9016

But copying the file to custom/include doesnt work.

How can I overwrite the corresponding file or function in the class in an upgrade-safe manner? If this is not possible, how can I format the date in

custom/modules/Tasks/metadata/subpanels/ForHistory.php

?

Thank you.