without the need to adjust it individually for every program. How can it be achieved?
It kind of cannot, because it is implemented individually within each program. The primary selection buffer is shared, yes, but the actual association of middle-click event with "paste from primary" is not (and neither is standard Ctrl-V clipboard, for that matter). Firefox handles it on its own, GTK-based apps let GTK handle most events, Qt-based apps let Qt handle them, etc.
So, for example, even if you forced the primary selection to remain always empty, it would not change how the apps behave – middle-clicking in Firefox would still lead to it trying to paste from primary instead of doing whatever else you expect it to do. Maybe it will change behavior if the buffer is empty, but more likely it won't.
(And the way primary selection is usually handled, unfortunately, is that toolkits bind its ownership to the literal "selection" (highlighted text) to visualize its contents. So if you had e.g. a clipboard manager that immediately clears the contents of the primary buffer to prevent paste, it would result in text getting immediately deselected in text editors...)
So your best option, most likely, is to find ways to disable middle-click paste at app or toolkit level. GTK3, for example, has an "enable-primary-paste" setting which can be set through its settings.ini or through GSettings:
gsettings set org.gnome.desktop.interface gtk-enable-primary-paste false
gsettings set org.cinnamon.desktop.interface gtk-enable-primary-paste false
gsettings set org.mate.interface gtk-enable-primary-paste true
(In an X11 environment the DE exports this as Gtk/EnablePrimaryPaste
through XSETTINGS, so if you're using GTK apps outside of a GNOME-based environment, xsettingsd might be used to publish it – or GTK's settings.ini can be edited directly.)
This option was added for GTK3 and later (GTK2 apps will not recognize it). Nothing for Qt either, unfortunately.