This is a sample Android application, written in Kotlin, that implements Android device owner mode.
Assuming you have installed the app (i.e. in Android Studio, or built and pushed an APK, etc), you can make your app device owner as follows:
adb shell dpm set-device-owner co.coburglabs.mdm/.DeviceOwnerReceiver
See my Medium article that describes this code in greater detail.