Let $\sigma(f)$ be the smallest $\sigma$-algebra on $[0,1]$ which makes $f$ measurable. I claim that $\overline{P_f} = L^2(I, \sigma(f), m)$, the space of all square-integrable $\sigma(f)$-measurable functions. In particular, $P_f$ is dense iff the completion of $\sigma(f)$ under $m$ contains all the Borel sets (equivalently, all the Lebesgue measurable sets).
One direction is easy: it is clear that $L^2(I, \sigma(f), m)$ is a closed subspace of $L^2(I, \mathcal{B}, m)$ (pass to an a.e.-convergent subsequence). And $P_f$ is clearly contained in the former, since any Borel function of $f$ remains $\sigma(f)$-measurable.
For the other direction, we use the multiplicative system theorem. This can be seen as a functional version of the monotone class theorem, or a measurable version of the Stone–Weierstrass theorem.
Theorem. Suppose $H$ is a vector space of real-valued bounded measurable functions on some measurable space $X$, which contains the constants and is closed under bounded pointwise convergence of sequences (i.e. if $f_n \in H$, $f_n \to f$ pointwise, and $|f_n| \le C$ for all $n$, then $f \in H$). Suppose $M \subset H$ is closed under pointwise multiplication, and let $\mathcal{G}$ be the $\sigma$-algebra generated by $M$ (i.e. the smallest $\sigma$-algebra on $X$ that makes all functions from $M$ measurable). Then $H$ contains all bounded $\mathcal{G}$-measurable functions.
You can find this (in a slightly stronger form) in Dellacherie, Probabilities and Potential, page 14, or in Janson, Gaussian Hilbert Spaces, appendix A. The proof is elementary and makes use of the classical Weierstrass approximation theorem.
Let $M = P_f$, which is obviously closed under multiplication.
Let $H = \overline{P_f} \cap L^\infty$ consist of all bounded measurable functions which are in the $L^2$-closure of $P_f$. Since $P_f$, its closure, and $L^\infty$ are all vector spaces, $H$ is a vector space. $H$ contains constants because $P_f$ did. And if $f_n \in H$ and $f_n \to f$ boundedly, then we also have $f_n \to f$ in $L^2$ by the dominated convergence theorem (using $C$ as the dominating function, since we are in a finite measure space). So $H$ satisfies all hypotheses.
Clearly $\mathcal{G} = \sigma(M) \supset \sigma(f)$, so the theorem asserts that $H$ contains all bounded $\sigma(f)$-measurable functions. Now for any $g \in L^2(I, \sigma(f), m)$, let $g_n = \max(-n, \min(g, n))$ be a truncation of $g$, which is bounded and still $\sigma(f)$-measurable. Then $g_n \in H \subset \overline{P_f}$ and $g_n \to g$ in $L^2$, so $g \in \overline{P_f}$.