If $f\in\mathbf{C}[[q]]$ is non-constant, and algebraic over $\mathbf{C}[q]$ (in the sense that it is a root of a polynomial with coefficients in in $\mathbf{C}[q]$) then can $f$ be the $q$-expansion of a modular form (for some congruence subgroup of $SL(2,\mathbf{Z})$)?

I ask for the following reason. There are geometers in my department who occasionally come up with $q$-expansions (probably from counting things in geometry) and ask if these things are likely to be modular forms. Sometimes they are, sometimes they aren't, sometimes I don't know. But one that came up today I noticed was non-constant and algebraic over $\mathbf{C}[q]$ and so I instantly said that this should rule it out, and then I realised I could not immediately point to a proof of this.

Katz proved many years ago that a non-constant polynomial in $q$ can't be the $q$-expansion of a modular form (by which I mean a form which has no poles, even at cusps), because if we have a non-constant polynomial modular form of some weight and level, we can consider all modular forms of that weight and level which are polynomials in $q$, and then it's not hard to check that this space is Hecke stable, but Hecke operators tend to increase the degree of a polynomial modular form if it has positive degree and it's not hard to finish the job now. See Katz Antwerp III, p94 (p26 of the article).

Now I've found the time to look at the article, I realise that probably modular forms algebraic over $\mathbf{C}[q]$ might also form a Hecke-stable subspace, although now one can't use the degree trick to finish.

I was half-expecting the result to be false in characteristic $p$, but now I'm not so sure. I know that the $\Delta$ function is $\sum_{n\geq1,n\ \mathrm{odd}}q^{n^2}$ in characteristic 2 but presumably this isn't algebraic over $\mathbf{F}_2[q]$; I realise now that I have no good test for this in my head.