You can use command line tool dpm from adb shell.
Usage:
usage: dpm [subcommand] [options]
usage: dpm set-device-owner <COMPONENT>
usage: dpm set-profile-owner <COMPONENT> <USER_ID>
dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
For more information check: dpm shell command
Note: Before using this command make sure that device is not provisioned. If device is provisioned and you get message like "Device is already provisioned" try the command after removing all the accounts from device or try after factory resetting the device.