Remember that the $var syntax is part of Grafana, not part of Prometheus. All the variables are substituted before the Prometheus even sees the query.
Maybe something like this would work (I've never tried it):
up{instance=~"$instance"} == $state
where $state is set to 0 or 1. But that's probably not what you want, as there's no "all" option.
Your question is about Grafana and how it handles local variables and drop-down selections, and how those variables interact with each other. You should be asking Grafana experts about whether it's possible in Grafana to configure what you want, and if so, how. Prometheus is the database backend, and simply answers the queries that Grafana sends to it.