MQTT: How to set UNDEF when invalid data returned from Zigbee2MQTT?

You probably want to chain a regex transform to filter out the empty messages. See MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters

Then create a new channel that filters for the messages that are blank and sets the Item to OFF when a blank is received.