Here is a way to do it.
Create an Automator Service that looks like the following:
The code in the Run Shell Script action is this:
if [[ `networksetup -getairportpower en1` == *On ]]
then
networksetup -setairportpower en1 off
else
networksetup -setairportpower en1 on
fi
Save the Service with a short name like, “ToggleWiFi"
Then, open Keyboard System Preferences and add a Shortcut to the new Service you created.
To create the service, open Automator and create a New Service.
Set it to Service receives no input in any application
Drag in a Run Shell Script action from the Utilities library.
Copy and paste the above code into the action, replacing “cat"
Save the Service.
Open Keyboard System Prefs
Click on Shortcuts Tab.
Select Services from the category list.
Scroll down and find your Service and set the shortcut.