We have the following PDE in $U$ an open bounded subset of $\mathbb{R}^2$: $$\begin{align} -\Delta u(x,y) + u(x,y) & =f(x,y) & & (x,y) \in U \\[8pt] u(x,y)& = g & & (x,y) \in \partial U \end{align}$$
We suppose also for simplicity that $g \in C^1(\partial U)$
The objective is to show uniqueness of solution for the weak formulation in $H^1(U)$.
Brezis' Functional Analysis, Sobolev Spaces and Partial Differential Equations [Proposition 9.22] asserts a weak solution for this problem is a function $u \in K$ satisfying $$ \quad \quad \quad \quad \quad \quad \int_{U} \nabla u \nabla v + \int_{U}uv= \int_{U}fv \quad \forall v \in H_0^1(U), \quad \quad \quad $$ where $K$ is defined as the convex and closed subset of $H^1(U)$ $$K= \{v \in H^1(U) \ | \ v-\tilde{g} \in H_0^1(U) \},$$ where $\tilde{g}$ verifies $\tilde{g}=g$ in $\partial U$.
Then he shows that indeed there is a unique $u_0 \in K$ that verifies the weak formulation given above.
Now, Does this imply that the solution is unique in $H^1(U)$, because showing uniqueness in this subset does seem to imply uniqueness in the whole space, arguing something that any function that is outside $K$ does not verify the boundary condition, although I need to formalize this.
By definition, the set $$ K = \{ v \in H^1(\Omega) : v - \widetilde g \in H_0^1(\Omega) \}.$$ is precisely the set of functions in $H^1(\Omega)$ satisfying the boundary condition $v|_{\partial \Omega} = g$, and the purpose of the condition $v - \widetilde g \in H_0^1(\Omega)$ is to impose this boundary condition. But as you say, we need to think carefully about how we formalise the boundary condition $v|_{\partial \Omega} = g$ for $v \in H^1(\Omega)$: since a general element $v$ of $H^1(\Omega)$ is really an equivalence class of functions that are equal almost everywhere, it makes no sense to simply "evaluate $v$ on $\partial \Omega$".
For $v \in H^1(\Omega)$, the boundary condition $v = g$ on $\partial \Omega$ is to be understood in terms of the trace map. In Evan's PDEs book (which I'm more familiar with), it is explained that the trace map is a bounded linear map $T : H^1(\Omega) \to L^1(\partial \Omega)$ such that $Tu = u|_{\partial \Omega}$ if $u \in H^1(\Omega) \cap C(\bar \Omega)$. A weak solution obeying the boundary condition $v|_{\partial \Omega} = g$ is then defined to be any weak solution $v \in H^1(\Omega)$ such that $Tv = g$. This definition agrees with the usual definition when $v \in H^1(\Omega) \cap C(\bar \Omega)$, but this definition continues to make sense when $v$ is not in $C(\bar \Omega)$.
Finally, there is a general theorem that says that, for all $u \in H^1(\Omega)$, $Tu = 0$ iff $u \in H_0^1(\Omega)$. (This is Theorem 5.5.2 in Evans.) So the condition that $Tv = g$ is equivalent to the condition that $v - \widetilde g \in H_0^1(\Omega)$. And that is the motivation for the definition of the set $K$.
Edit: If you wish to avoid traces altogether (because Brezis avoids traces - see comment below), then take a look at Brezis Theorem 9.17. It says that, when $v \in H^1(\Omega) \cap C(\bar \Omega)$, the condition that $v|_{\partial \Omega} = g$ is equivalent to the condition that $v - \widetilde g \in H_0^1(\Omega)$. But of course, the statement $v- \widetilde g \in H_0^1(\Omega)$ continues to be meaningful even when $v$ is not in $C(\bar \Omega)$, which is why we prefer it.