How to bootstrap CiviCRM with admin permissions in a Wordpress environment?
If wp-cli is an option, it takes a --user option, similarly to drush.

If that's not an option, looking at the wp-cli source code (here) suggests that wp_set_current_user() will do the trick.