It is known that the twisting of the Fourier expansion of a modular forms by a Dirichlet character produce a modular form.
My question: Can we reverse this machine?
More precisely, let $N\in \mathbb{N}$, $\chi$ be a Dirichlet character mod $N$.
Let $f\in M_k(\Gamma_0(N),\chi^2)$ with a Fourier expansion of the form
$$f(\tau)=\sum_{n\in \mathbb{N}}\chi(n) a(n) q^n.$$
Set
$$g(\tau)=\sum_{n\in \mathbb{N}} a(n) q^n.$$
Is $g(\tau)$ a modular form, which level and character?
Bests
You have to decide what $a(n)$ should be when $n$ is not coprime to $N$, in which case $\chi(n)$ is 0 so the formula for $f(\tau)$ does not define $a(n)$ uniquely. If you assume that $a(n)$ is 0 for all such $N$, then $g(\tau)$ is just the twist of $f(\tau)$ by the character $\chi^{-1}$, so it is certainly a modular form, of trivial character and level dividing $N^3$ or something like that (maybe $N^2$; the bible for such results is Atkin and Li's paper "Twists of newforms and pseudo-eigenvalues of W".)