Apple Script Solution
Copy the code into the file ~/Library/Scripts/proxytoggle.applescript
set socksStatus to do shell script "networksetup -getsocksfirewallproxy Wi-fi | grep Enabled"
if (offset of "Yes" in socksStatus) = 0 then
do shell script "networksetup -setsocksfirewallproxystate Wi-fi On"
display notification "Proxy Enabled !"
else
do shell script "networksetup -setsocksfirewallproxystate Wi-fi Off"
display notification "Socks disabled"
end if
Then in Script Editor.app
under Preferences
tab I enabled Show Script menu in menubar
checkbox (annotated in red):

as you can see, when you run the code it enable the proxy and if you run it again it will be disable.
Have a great day !