[ST Edge] How to check online/offline status of device in a routine?

No, it cannot be set through a SmartApp, but you can try using Edge drivers for your Zigbee and Z-Wave devices, they handle the device health automatically.
In the DTH, you had to enroll for the health check depending on the protocol but you don’t need to do that now.
There are some drivers already available here which you can have access to by enrolling your Hub in this channel (see more info about that at the bottom of this post.