Each device has it's specifics to make a factory reset, if the manufacturer of your device is using IoT Plug and Play then there is a chance that you have a built-in capability command to perform factory reset.
Please take a look at the following documentation to better understand how to build your IoT hardware product that supports IoT Plug and Play:
If you want to use a device with IoT Plug and Play you can search for it in the Certified for Azure IoT device catalog.
For example this device has a IoT Plug and Play command to reboot:
Thanks for the question @Iotiot.in . If I was able to answer it, please mark it as answer :)!