Suppose that you have a generating function
$$
f(q) = \sum_{k=0}^\infty a_k q^k
$$
It's not too hard to obtain the generating function
$$
f_{n,m}(q) = \sum_{k=0}^\infty a_{nk + m}q^k
$$
by taking a creative sum of terms like $f(\zeta_n^i q)$ for appropriate roots of unity $\zeta_n$.

What about functions of the form
$$
g(q) = \sum_{k=0}^\infty a_{k^2}q^k
$$
or more generally,
$$
g_{n,m}(q) = \sum_{k=0}^\infty a_{nk^2+m}q^k
$$

Is there some way to nicely obtain these in terms of either the original generating function, or its coefficients, or anything? If it helps, the generating function in question does satisfy some modular properties.