How to disable MTP and PTP file sharing via USB on Android 5?
Thanks to @Firelord, this is the procedure to follow:


Root your phone
Install Terminal Emulator
In Terminal Emulator, run su sh -c 'echo -n none &gt; /data/property/persist.sys.usb.config'
Restart the phone


Bonus: Now you can get rid of all those horrible vendor apps. Bye Samsung and Three!

Caveat 1: USB debugging no longer works after doing this, regardless of whether you left it enabled while following the instructions or disabled and re-enabled it. All you need to do (I just verified it) is to set the value back to adb to make it work again, but then of course you have the original problem. If there’s a magic string to make USB debugging work and simultaneously disable both MTP and PTP, I don’t know what it is (I tried with none,adb).

Caveat 2: You can’t update Android anymore without completely resetting your device. Not even de-rooting and a factory reset work - bloody Android still says I’ve made an “unauthorized modification.” Let’s recap: “Freedom 0: The freedom to run the program as you wish, for any purpose.” I had to boot into Windows and use Samsung Smart Switch for PC to upgrade.