Let $U\subset \Bbb{R}^n$ be the bounded sufficient smooth open set, let $g\in H^1(U)$, and let $\{w_k\}$ be a sequence of the orthonormal basis for $L^2(U)$ and orthogonal basis in $H^1(U)$ (which can be constructed using the eigenfunction of the $-\Delta$).
Prove the finite truncated sequence $$u_m = \sum_{i=1}^m (g,w_k)_{L_2(U)}w_k$$
satisfies the Bessel inequality in $H^1(U)$,that is $$\|u_m\|_{H^1 }\le \|g\|_{H^1}$$ The problem is I'm not sure does the equality holds?
$$Dg = D\sum_{k=1}^\infty (g,w_k)w_k = \sum_{k=1}^\infty(g,w_k)Dw_k$$?Since I'm not sure if $D$ is a continuous operator?
The idea is that you construct $w_k$ out of an eigenvalue problem for the laplacian (it's definitely not true for any basis of $L^2(U)$).
I'll assume that $w_k$ is an eigenfunction of $-\Delta$ with zero Dirichlet boundary conditions (it also works if you have zero Neumann conditions).
Let $k,l\in \mathbb{N}$, then $$ (Dw_k, Dw_l)_{L^2}= (w_k, -\Delta w_l)_{L^2} = \lambda_l(w_k, w_l)_{L^2} = \lambda_l \delta_{kl}, $$ where $\delta_{kl}$ is the Kronecker delta.
Define $g:= \sum_{j=1}^k \alpha_jw_j$ for some scalars $\alpha_j$. By the above computation we have $$ (g,g)_{H^1} = \sum_{j=1}^k |\alpha_j|^2 + \sum_{j=1}^k \lambda_j |\alpha_j|^2, $$ Then we get, with your notation, $$ (u_m, u_m)_{H^1}= \sum_{j=1}^m |(g,w_j)_{L^2}|^2 + \sum_{j=1}^m \lambda_j |(g,w_j)_{L^2}|^2. $$ The inequality then follows in this case (notice that we actually have equality if $m\geq k$). Thus we have $$ \| u_m\|_{H^1}\leq \| g\|_{H^1}, $$ when $g$ is a finite linear combination of the $w_k$. Now let $k$ in the definition of $g$ go to infinity (notice that for $k>m$ the definition of $u_m$ doesn't change) to get the inequality for general $g\in L^2$ (where for $g\notin H^1$ we interpret the RHS as $\infty$).