How do I programmatically change the admin theme?
As the context module is still in alpha I would try a solution in custom code by extending the class AdminNegotiator:

src/Theme/CustomAdminNegotiator.php

&lt;?php

namespace Drupal\mymodule\Theme;

use Drupal\user\Theme\AdminNegotiator;
use Drupal\Core\Routing\RouteMatchInterface;

class CustomAdminNegotiator extends AdminNegotiator {

  public function determineActiveTheme(RouteMatchInterface $route_match) {
    if (in_array('custom_role', $this-&gt;user-&gt;getRoles())) {
      return 'custom_admin_theme';
    }
  }

}


and register this service class in mymodule.services.yml tagged as theme negotiator with a priority higher than the default admin negotiator (-40):

services:
  theme.negotiator.admin_theme.custom:
    class: Drupal\mymodule\Theme\CustomAdminNegotiator
    arguments: ['@current_user', '@config.factory', '@entity.manager', '@router.admin_context']
    tags:
      - { name: theme_negotiator, priority: -39 }


The applies() method is kept the same as in AdminNegotiator, so that only users with the correct permission have access to this theme and this only applies for admin routes.