Make sysctl changes at startup
It's probably best to ditch the script approach and use the settings file designed for this purpose: sysctl.conf

This applies up to macOS 10.12 Sierra.
as @klanomath pointed out in comments: " *.deadtimer are all "sysctl: unknown oid *.deadtimer" in my High Sierra environment. IE they don't exist!"
So it looks like that part of the sysctl interface is completely gone now.

sudo nano  /private/etc/sysctl.conf


add the following variables:

net.smb.fs.kern_deadtimer=0
net.smb.fs.kern_hard_deadtimer=0
net.smb.fs.kern_soft_deadtimer=0


If you afterwards boot in verbose mode (cmd+v on startup or sudo nvram boot-args="-v" before a reboot), you should see the custom settings being applied.

You should then see on boot messages like these:

net.smb.fs.kern_deadtimer: 60 -&gt; 0
net.smb.fs.kern_hard_deadtimer: 600 -&gt; 0
net.smb.fs.kern_soft_deadtimer: 30 -&gt; 0


Otherwise check with 

sysctl -a | grep smb


This approach should work for most settings that are accessible via sysctl and thus be as generalised as the question title implies.