How this works in general is that package maintainers of a distribution take the original sources from the official source (GitHub, SourceForge etc.; the upstream code) which usually come as a tarball (a compressed tar archive). And those remain as they are; pristine as it is called.
But typically some adaptations need to be made so everything works well together with the overall distribution. So the package maintainer unpacks those pristine sources into a working directory and changes the source as needed; and then uses the diff
command to generate the change set, i.e. the few places that were really changed between the original and the now modified ("patched") version.
This change set is called a diff or a patch. For each package, there can be one of them, or multiple; typically they are organized by topic; i.e. one for paths that are different on the target distribution, another one to work around quirks of another program that is called by this software etc.; you get the idea.
That original tarball and the diffs / patches are then put into another archive (a source package), but kept separate enough so everything remains transparent.
When the package is now built, that means that first the original tarball is unpacked, then the first patch is applied (using the patch
program), then the second etc.; and when that patching stage is complete, the compile process is really started (calling make
and make install
and whatever else is necessary).
That is done in all Linux distributions that I know; Ubuntu, Debian, SUSE, Red Hat, you name it. Probably it's the same for all, and probably also for BSD variants.
So, there are the source packages; and this is where you come in. Nothing prevents you from taking a source package and add another patch or two on top of it; and generate your own source package based on that.
The caveat is that now you'll have to rebuild the package yourself; and to make sure to add your patches to a new version of the source package whenever a new one is released, i.e. for every package update.
That can be done, but it's tedious. Chances are that you run out of motivation to do that all the time; depending on how often the package really changes.
One tool to ease the pain is the openSUSE Build System (OBS) that supports automating at least part of it. But you still have to take care of re-importing source packages and adding your own patches. It's available for free on the web, and it can build packages for various distributions, including not only openSUSE, but also Ubuntu, Debian and others.
So, if you have a change that is of general interest, you might want to approach the package maintainers of your distribution if they don't want to include your changes in their source package. Or you might contact the upstream authors (those who wrote the software originally) if they don't want to publish your changes for everyone.
If it's something very specific for your use case, that won't work, obviously. In that case, think about a different strategy.