How should I modify a contrib module?
If your addition is general and not specific to your site, you could create an issue and post a patch there.

And even if you have a site specific extension, maybe it can be solved in a way that just requires an additional hook to the contrib module itself which could be useful for other use cases as well. Then you could again create an issue for that.