Hide/Show Battery Icon in Menu Bar with AppleScript
Update: This updated script wouldn't flash through the screen, i.e runs in the backgound. The old version is still valid. 

tell application "System Events"
    tell process "System Preferences"
        activate
    end tell
    tell application "System Preferences"
        set current pane to pane "com.apple.preference.energysaver"
    end tell
    tell process "System Preferences"
        click checkbox 1 of window 1
    end tell
    tell application "System Preferences"
        quit
    end tell
end tell


From Oct. 18th:

-- Allow Script Editor in Accessibility &lt;- Privacy &lt;- Security &amp; Privacy &lt;-  System Preferences. For testing, at the very least.

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.energysaver"
end tell


tell application "System Events"
    tell process "System Preferences"
        tell window 1
            click checkbox 1
        end tell
    end tell
end tell

tell application "System Preferences"
    quit
end tell

-- Create an Automator Service with this, so that you can bind the action to a keyboard shortcut.