karman you will need to use the IOC container to register class bindings. This allows you to say that when the container is asked for the base class, it needs to return your own custom class.
If you have never worked with the Laravel IOC container, there are many tutorials on the web. Most of the Laravel stuff is applicable to Flarum as well in that domain.
There are examples of Flarum extensions doing this kind of stuff, but I'm unsure which one to link as an example as it's usually highly specific. The process is usually to create a compatible class, usually by extending the original or implementing the same interface, then bind it using the container to replace the base class.
It should be noted this must be the last resort, since only one extension will be able to override a binding at a time, and this is very likely to break between Flarum updates. Most things can be changed in Flarum through our PHP extenders and events. Unfortunately this is one case that isn't covered by extenders or events.