You can also listen for the onSlotRenderEnded event:
window.googletag.pubads().addEventListener('slotRenderEnded', function (e) {
if (e.isEmpty) {
const elementId = e.getSlotElementId();
// Use this ID to then select the HTML you would like to hide
}
});