Condition for martingale
Let $X_t = B_t^2$, so that by Itô's lemma we have $$dX_t = dt + 2B_t dB_t$$ For $f \in C^{2,1}$, we set $Z_t = f(X_t, t) = f(B_t^2,t)$ and apply Itô's lemma again to get: $$\begin{align*} dZ_t &= f_t(X_t, t) dt + f_x(X_t, t) dX_t + \frac{1}{2}f_{xx}(X_t, t)(dX_t)^2 \\ &= \left( f_t(X_t, t) + 2X_t f_{xx}(X_t, t) + f_x(X_t, t) \right) dt + 2B_tf_x(X_t, t) dB_t \\ &= \left( f_t(B_t^2, t) + 2B_t^2 f_{xx}(B_t^2, t) + f_x(B_t^2, t) \right) dt + 2B_tf_x(B_t^2, t) dB_t \end{align*}$$
Thus, for $Z_t$ to be driftless, you need $f_t(B_t^2, t) + 2B_t^2 f_{xx}(B_t^2, t) + f_x(B_t^2, t) = 0$, which is a PDE that can be solved for $f$. This guarantees that $Z_t$ is a local martingale. For $Z_t$ to be a true martingale, then a sufficient condition would be that $B_t f_x(B_t^2, t)$ is in $L^2$.