Approximation of functions mesurable w.r.t a generated $\sigma$-algebra. $\newcommand{\vp}{\varphi}$ $\newcommand{\mc}{\mathcal}$ $\newcommand{\C}{\mathbb C}$
Let $(X, \mc X, \mu)$ be a probability space and $\mc F$ be subset of $L^2_\mu$.
Let $\mc Y$ be the $\sigma$-algebra generated by $\mc F$.
I want to show the following

Problem. Assuming $\mathcal F$ is an algebra*, I want to show that if $f\in L^2_\mu$ is $\mc Y$-measurable then $f$ can be approximated arbitrarily well in $L^2$ by linear combinations of products of functions in $\mc F$.

This was mentioned in here by @JohnGriesmer in this answer.
Perhaps a better way to say the above is the following.
Suppose $\mc A\subseteq L^2_\mu$ is an algebra, that is $\mc A$ is closed under products and linear combinations, and $\mc Y$ is the $\sigma$-algebra generated by $\mc A$.
Then any $\mc Y$-measurable function in $L^2_\mu$ can be approximated arbitrarily well by members of $\mc A$.
Attempt.
I considered the problem in a simple case where I was able to show that the desired result indeed holds:
Let $X$ be the unit interval $[0, 1]$ and $\mc X$ be the Borel $\sigma$-algebra on $X$.
Let $\mu$ be the Lebesgue measure.
Define $\mc F\subseteq L^2$ be the algbera generated by the singleton containing the function $\vp:=1_{[0, 1/2)} + 2\cdot 1_{[1/2, 1]}$, and $\mc Y$ be the $\sigma$-algebra generated by $\mc F$.
For convenience write $A=[0, 1/2)$ and $B=[1/2, 1]$.
Clearly, then $A$ is in $\mc Y$, and thus $f:=1_A$ is a $\mc Y$-measurable function.
I want to show that $f$ can be approximated in $L^2$ by functions of the type $\sum_{k}c_k \vp^k$, where $c_k\in \C$.
Note that $\vp^k = 1_A + 2^k\cdot 1_B$.
Thus $\sum_k c_k\vp^k = (\sum_k c_k)1_A + (\sum_k 2^kc_k)1_B$.
So if we can find $c_k$'s such that $\sum_k c_k$ is close to $1$ and $\sum_k 2^kc_k$ is close to $0$ then we can succeed with the approximation.
And indeed such $c_k$ can be found.
But this toy case does not seems to lend to a generalization.
*: The assumption that $\mathcal F$ is an algebra was not present at first. @Rerain gave a counterexample and only then I have added this assumption. By an algbera we mean a linear subspace closed under products.
 A: First consider the case $\mathcal{F} = \{g\}$. Then $f$ and $g$ are both $\mathcal{Y}$-measurable and to approximate $f$ it suffices to approximate characteristic functions of sets in $\mathcal{Y}$ by polynomials in $g$.
Let $Y \in \mathcal{Y}$ and $\varepsilon \gt 0$. There is a $b$ such that $\mu(g^{-1}([-b,b])) \gt 1-\frac{1}{3}\varepsilon$. There are intervals $I_1,\ldots,I_k$ such that $$\mu\left(Y \,\Delta\,\, g^{-1}\left(\bigcup_i I_i\right)\right) \lt \frac{1}{3}\varepsilon.$$By Lusin's theorem, there is a measurable set $B\subseteq[-b,b]$ with $\mu(g^{-1}([-b,b] \setminus B)) \lt \frac{1}{3}\varepsilon$ and a continuous function $h:[-b,b]\rightarrow\mathbb{R}$ such that $\mathbf{1}_{\bigcup_i I_i} = h$ on $B$, so by the Weierstrass approximation theorem, there is a polynomial $p$ such that$$|p(x) - \mathbf{1}_{\bigcup_i I_i}(x)| \lt \varepsilon$$for all $x \in B$. Then we have$$|p(g(\omega)) - \mathbf{1}_Y(\omega)| \lt \varepsilon + |\mathbf{1}_{\bigcup_i I_i}(g(\omega)) - \mathbf{1}_Y(\omega)| = \varepsilon$$for all $\omega \in A := g^{-1}(B) \setminus (Y \Delta\, g^{-1}(\bigcup_i I_i))$ and $$\mu(A) \gt 1 - \frac{1}{3}\varepsilon - \frac{1}{3}\varepsilon - \frac{1}{3}\varepsilon = 1 - \varepsilon.$$ So we can indeed find polynomials $p$ such that $p \circ g$ uniformly approximates $\mathbf{1}_Y$ arbitrary closely, on an arbitrary large part of $X$.
Now let $\mathcal{F}$ be arbitrary again and let $\mathcal{Z}$ be the set of all those sets in $\mathcal{Y}$ whose characteristic function can be approximated by products of polynomials of functions in $\mathcal{F}$. Then$$\mathcal{Y} = \sigma(\mathcal{E})\textrm{, with }\mathcal{E} := \bigcup_{g \in \mathcal{F}} g^{-1}(\mathcal{B}),$$and we have just shown $\mathcal{E} \subseteq \mathcal{Z}$. If we can show that $\mathcal{Z}$ is a $\sigma$-algebra, $\mathcal{Y}\subseteq\mathcal{Z}$ follows.
We show that $\mathcal{Z}$ is closed under the taking of complements and countable intersections.
If $Z\in\mathcal{Z}$ and $z_1,z_2,\ldots:X\rightarrow\mathbb{R}$ approximate $\mathbf{1}_Z$, then $1-z_1,1-z_2,\ldots$ approximate $\mathbf{1}_{Z^c}$. So $Z^c\in\mathcal{Z}$.
If $Z_n\in\mathcal{Z}$ and $z_{n,1},z_{n,2},\ldots:X\rightarrow\mathbb{R}$ approximate $\mathbf{1}_{Z_n}$, for $n\in\mathbf{N}$, then, since$$\mathbf{1}_{\bigcap_{i\in\mathbb{N}}Z_i} = \prod_{i\in\mathbb{N}} \mathbf{1}_{Z_i}$$we can choose finite products of appropriate $z_{k,n}$ as our approximations of $\mathbf{1}_{\bigcap_{i\in\mathbb{N}}Z_i}$, and choosing the relevant $\varepsilon$'s to ensure convergence is clearly possible.
So $\mathcal{Z}$ is a $\sigma$-algebra. Therefore $\mathcal{Y} \subseteq \mathcal{Z}$, so all $\mathcal{Y}$-measurable functions can be approximated in the desired way.
A: I think I've found a counterexample.
Let the probability space $(X,\mathcal{X},\mu)$ be given by$$X=[1,\infty),\quad \mathcal{X}=\mathcal{B}(X),\quad \mu([a,b])=\int_a^b 3x^{-4}\textrm{d}x$$and let $\mathcal{F} = \{g\}$ with $g:X\rightarrow\mathbb{R}, x \mapsto x$. Then$$\int_X |g^a|^2\textrm{d}\mu = \int_1^\infty 3x^{2a-4}\textrm{d}x \lt \infty \quad \iff \quad a\lt\frac{3}{2},$$so the only products of functions in $\mathcal{F}$ that are actually in $L_\mu^2$ are $g$ itself and $x \mapsto 1$ (the empty product).
On the other hand, $\mathcal{Y} = g^{-1}(\mathcal{B}(\mathbb{R})) = \mathcal{X}$, so $$f:X\rightarrow\mathbb{R}, x \mapsto \sqrt{x}$$ is $\mathcal{Y}$-measurable and in $L_\mu^2$. If we try to $L_\mu^2$-approximate $f$ with polynomials $p_n$, any greater-than-linear terms will blow up, so $p_n$ must be affine-linear. Let $q_{r,s}$ be the affine-linear function that is equal to $f$ at $r$ and $s$ (so $q_{r,r}$ is a tangent to $f$) and let $r_n$, $s_n$ be such that $1 \le r_n \le s_n$ and $p_n=q_{r,s}$ ($p_n$'s that aren't a tangent to or intersect twice with $f$ are worse approximations than those who are or do, so we can ignore them). Since $f$ is strictly convex, this implies:
If $1 \le r_n \le s_n \le 3$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_3^\infty |p_n-f|^2\textrm{d}\mu \ge \int_3^\infty |q_{3,3}-f|^2\textrm{d}\mu \gt 0,$$
if $2 \le r_n \le s_n$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_1^2 |p_n-f|^2\textrm{d}\mu \ge \int_1^2 |q_{2,2}-f|^2\textrm{d}\mu \gt 0,$$
and if $1 \le r_n \le 2$ and $3 \le s_n$, then$$\int_X |p_n-f|^2\textrm{d}\mu \ge \int_2^3 |p_n-f|^2\textrm{d}\mu \ge \int_2^3 |q_{2,3}-f|^2\textrm{d}\mu \gt 0.$$
Every $p_n$ falls under at least one of the three cases and the rightmost integrals are independent of $n$, so $p_n$ cannot $L_\mu^2$-converge against $f$.
A: $\newcommand{\set}[1]{\{#1\}}$ $\newcommand{\mr}{\mathscr}$ $\newcommand{\mc}{\mathcal}$ $\newcommand{\R}{\mathbf R}$ 
The following lemma etablishes the desired result under some additional assumptions of the algebra of functions. The notation here is a bit different from the one used in the OP.

Lemma.
  Let $\mr A\subseteq L^2(X)$ be an algebra of functions such that
  * $\mr A$ closed under complex conjugates.
  * $\mr A$ is closed under taking absolute values.
  * All constant functions are in $\mr A$.
  Let $\mc A$ be the $\sigma$-algebra generated by $\mr A$.
  Then for any $A\in \mc A$, there is a sequence of functions in $\mr A$ which converge to $1_A$ in the $L^2$-norm.
  In other words, $1_A$ is in the $L^2$-closure of $\mr A$.

Proof.
First note that since $\mr A$ is closed under complex conjugation, $\mc A$ is same as the $\sigma$-algebra generated by the real-valued functions in $\mr A$.(What we are using here is that for any two measurable functions $f$ and $g$ we have $\sigma(f, g) = \sigma(f+g, f-g)$).
Note that whenever $f$ and $g$ are real valued functions in $\mr A$, then $\max(f, g)$ and $\min(f, g)$ are in $\mr A$.
Define $\mc Y$ as the set of all measurable subsets of $X$ whose characteristic function is in $\overline{\mr A}$.
Clearly $\overline{\mr A}$ is a linear subspace of $L^2$ which is also closed under complex conjugation and absolute values.
Thus if $E, F\in \mc Y$, we have $1_{E\cup F} = \max\set{1_E, 1_F}$, and thus $E\cup F$ is in $\mc Y$.
Similarly $E\cap F$ is in $\mc Y$.
Also, $\mc Y$ is closed under complements, and thus $\mc Y$ is an algebra of sets.
We show that it is in fact a $\sigma$-algebra.
Indeed, if $E_1, E_2, E_3 , \ldots$ are in $\mc Y$, then defining $F_k=E_1 \cup \cdots \cup E_k$ we have $1_{F_k}$ converges to $1_E$, where $E=\bigcup_{i=1}^\infty E_i$, in the $L^2$-norm.
Since each $1_{F_k}$ is in $\mr A$, we deduce that so is $1_E$, and hence $\mc Y$ is closed under countable unions.
This shows that $\mc Y$ is a $\sigma$-algebra.
Now let $f\in \mr A$ be real valued and $A=\set{x:\ f(x)> 0}$. 
We will show that $1_A$ can be approximated by functions in $\mr A$ in the $L^2$-norm.
Define $f_n=\min(1, n\max(f, 0))$ and note that each $f_n \in \mr A$.
Then one can check that $f_n\to 1_A$ pointwise.
Thus $f_n-1_A$ converges to $0$ pointwise.
Applying the dominated convergence theorem we infer that $f_n\to 1_A$ in $L^2$.
By the same reasoning we can show that the characteristic function of $f^{-1}(I)$ can be approximated in $L^2$ by members of $\mr A$.
This shows that $f^{-1}(I)$ is in $\mc Y$ whenever $f\in \mr A$ and $I$ is an interval in $\R$.
Since $\mc Y$ is a $\sigma$-algebra, we conclude that $\mc Y$ contains $\mc A$, and we are done.
$\blacksquare$
