Let $(\Omega, \mathcal{F}, \mathbb{P})$ be a probability space and $X$ be a real-valued random variable such that $\mathbb{E}|X|<\infty$. Let $\mathcal{G} \subset \mathcal{F}$ be a sub- $\sigma$ -algebra of $\mathcal{F}.$ Prove that there exists a $\mathcal{G}$ -measurable random variable ${Y}$ such that $$ \mathbb{E} X \mathbb{1}_A =\mathbb{E} Y \mathbb{1}_{A} \quad \forall_{A \in \mathcal{G}} $$ We usually write $Y=\mathbb{E}(X \mid \mathcal{G})$ and call $Y$ a conditional expectation of $X$ with respect to $\mathcal{G}$
My sketch: Suppose that $X$ is non-negative. Define $\mu$ on sub $\sigma$- algebra $\mathcal{G}$ by $\mu(\mathcal{G}) = \mathbb{E}X_{\mathbb{1}_{\mathcal{G}}}$. We have $\mu \ll \mathbb{P}$
Hence, Radon Nikodym says that there is a random variable $Y=\mathbb{E}(X\mid A) > 0$ such that for all sets $A \in \mathcal{G}$ we have
$$ \mathbb{E} X \mathbb{1}_{A}=\mathbb{E}(X\mid A) $$
Question: This is good proof? How to prove this for negative?
It is important to mention that you are applying RNT to the space $(\Omega, \mathcal G)$ (and not $(\Omega, \mathcal F)$) with the mesures $\mu$ and $\mathbb P$. That is the reason you get a $\mathcal G$ measurable random variable $Y$.
For the general case just use $X=X^{+}-X^{-}$ as mentioned by Math1000.