Edit: this stopped working with the first June 2023 update of Home Assistant because of Complete persistent notifications migration by bdraco · Pull Request #92828 · home-assistant/core · GitHub, state is always unknown now 
Edit 2: the fix is in Disable or hide notifications? - #11 by VDRainer
Checking if persistent notification exists works for me with the following:
condition: template
value_template: '{{ states(''persistent_notification.my_notification_id'') != ''unknown'' }}'
When notification is not present:
When notification is present:
Inspired from How to test whether an entity exists? - #2 by VDRainer

