I found the following result in Brezis' book.
Let $\Omega$ be a bounded open set of class $C^1$. Let $d(x):=\operatorname{dist}(x,\partial\Omega)$. Then there exists $C>0$ such that $$ \|\frac{u}{d} \|_{L^2(\Omega)}\le C\|\nabla u\|_{L^2(\Omega)}\qquad\forall\ u\in H^1_0(\Omega). $$ Viceversa, if $u\in H^1(\Omega)$ is such that $\frac{u}{d}\in L^2(\Omega)$, then $u\in H^1_0(\Omega)$.
I'm wondering if the first implication of the statement still holds with the following hypotheses.
Let $\Omega$ be a Lipschitz domain and let $\Gamma\subsetneq\partial\Omega$ be "good enough". $d(x):=\operatorname{dist}(x,\Gamma)$. Then there exists $C>0$ such that $$ \|\frac{u}{d} \|_{L^2(\Omega)}\le C\|\nabla u\|_{L^2(\Omega)}\qquad\forall\ u\in H^1_{0,\Gamma}(\Omega). $$
I guess I found the answer in this paper: https://link.springer.com/article/10.1007/s11118-015-9463-8