Yubikey usbkill

Is there any way to setup yubikey to function similarly to usbkill GitHub - hephaest0s/usbkill: « usbkill » is an anti-forensic kill-switch that waits for a change on your USB ports and then immediately shuts down your computer. where your pc immediately shuts off and locks if the yubikey is removed or another usb change is detected?