First, I would never rely on solutions which are blindly navigating through the UI as suggested in most answers here. More in a note below.
I like the G murali's first answer which suggests the following to enable the airplane mode:
adb shell settings put global airplane_mode_on 1
Unfortunately, it doesn't work. It just changes the state of the Airplane mode icon, but all radios are still active.
It's missing one very important part, which is broadcasting the intent right after the setting has been changed to inform applications that the Airplane mode state has changed.
To enable the Airplane mode use the following commands:
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
To disable the Airplane mode, you have to chnage the setting to 0 and broadcast the intent again:
adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
It's tested and working on Android 6.
Note
Many answers suggest to use an activity to open the Airplane mode settings and then simulate some key presses to navigate through the UI. I don't recommend to rely on that. There may be just a short lag on the device and keys will be pressed before the Settings dialog is opened or for example some unexpected dialog will appear meanwhile. In both cases the key presses will cause something unintended, possibly harmful.
Also the UI may be different on devices of various brands, models, Android versions, etc. I have tested it on Samsung Galaxy S4 (Android 6.0.1) and it didn't work there. It may be by a difference between the Samsung's and the default UI.
The settings manipulation method should be perfectly safe.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…