Let $\mathcal M\_m$ be the set of $2$-by-$2$ **primitive** (relatively prime entries) matrices with determinant $m$. Let $\alpha \in \mathcal M\_m$ and let $\Gamma\subset \operatorname{SL}\_2(\mathbb Z)$. Define
$$R\_{\alpha,\Gamma}=\lbrace M\in \Gamma\backslash\mathcal M\_m : M \equiv \alpha \text{ in } \Gamma\backslash\mathcal M\_m/\Gamma\rbrace.$$ Thus $R\_{\alpha,\Gamma}$ is a set of representatives $M$ for the left action of $\Gamma$ on $\mathcal M\_m$ such that there exist matrices $A,B\in \Gamma$ with the property $M=A\alpha B$. 


Let $F\_{N,\mathbb C}$ be the field of modular functions of level $N.$ Suppose that $f\in F\_{N,\mathbb C}$, $\mathbb C(j)\subset \mathbb C(f)$, and $\alpha \in \mathcal M\_m$. The Galois group of $F\_{N,\mathbb C}$ over $\mathbb C(j)$ is isomorphic to $\operatorname{SL}\_2(\mathbb Z/N\mathbb Z)/\{\pm 1\}$. The subgroup corresponding to the subfield $\mathbb C(f)$ is 
$$\Gamma(f)=\lbrace A\in\operatorname{SL}\_2(\mathbb Z/N\mathbb Z): f\circ A = f\rbrace.$$


It is easy to see that $f\circ \alpha \in F\_{mN,\mathbb C}$, and that the minimal polynomial of the function $f\circ \alpha$ over $\mathbb C(f)$ is 
$$\prod\_{M\in R\_{\alpha, \Gamma(f)}}X-f\circ M.\label{m}\tag{1}$$


Suppose that in addition $f$ has **rational** Fourier coefficients. Is the polynomial above the also the minimal polynomial of $f\circ\alpha$ over the field $\mathbb Q(f)$? 


**Update**


The result is true when $\alpha = \begin{pmatrix}m & 0 \\0& 1\end{pmatrix}$. In this case the function $f\circ \alpha$ has rational Fourier coefficients. It is therefore invariant under the action of $(\mathbb Z/mN\mathbb Z)^\times$ on $F\_{N}$.


To show that the polynomial $\eqref{m}$ in question is also the minimal polynomial of $f\circ\alpha$ over $\mathbb Q(f)$, we must show that the set of roots of $\eqref{m}$ is stable under all automorphisms fixing $\mathbb Q(f)$. Each such automorphism can be represented as 


$$\begin{pmatrix}d & 0 \\0& 1\end{pmatrix}\gamma,$$


where $\gamma \in \Gamma(f)$ and $d\in (\mathbb Z/mN\mathbb Z)^\times$. This is because $\operatorname{Gal}(F\_{mN}/\mathbb Q(j)) \cong \operatorname{PGL}\_2(\mathbb Z/ mN\mathbb Z)$.
Since $f\circ\alpha(z)=f(mz)=\sum\_ka\_kq^{mk/N}$ has rational coefficients, the matrix $ \begin{pmatrix}d & 0 \\0& 1\end{pmatrix}$ acts trivially on $f\circ\alpha$. The set $R\_{\alpha,\Gamma(f)}$ is stable under the action of $\gamma$ by definition.


**Update II**


We prove that the result is true when both $f$ and $f\circ\alpha$ have rational Fourier coefficients. Let $k=mN$. First note that if $d\in(\mathbb Z/k\mathbb Z)^\times$ and $\gamma \in \Gamma(f)$ then any lift to $\operatorname{SL}\_2(\mathbb Z)$ of the matrix 
$$\begin{pmatrix}1 & 0\\0& d\end{pmatrix}\gamma\begin{pmatrix}1 & 0 \\0& d\end{pmatrix}^{-1}$$
also lies in $\Gamma(f)$ because it has determinant equal to $1$ and the automorphism induced by it fixes $f$ (here we use that $f$ has rational coefficients).


We know that $F\_k=\mathbb Q(j,h^{(r,s)}:(r,s)\in \mathbb Z^2, \not \in k\mathbb Z^2)$, where 
$$h^{(r,s)}(\tau)=\frac{g\_2(\tau)}{g\_3(\tau)}\wp\_\tau\left(\frac{r\tau+s}{k}\right)$$
are the Fricke functions. They satisfy $h^{(r,s)\gamma}=h^{(r,s)}\circ\gamma$ for $\gamma\in \operatorname{SL}\_2(\mathbb Z)$, and $(h^{(r,s)})^{\sigma\_d}=h^{(r,sd)}$ where $\sigma\_d$ is the automorphism induced by $d\in(\mathbb Z/k\mathbb Z)^\times$.


Let $M\in R\_{\alpha,\Gamma(f)}$. We must show that for each $d\in(\mathbb Z/k\mathbb Z)^\times$ we have $(f\circ M)^{\sigma\_d}=f\circ M'$ for some $M'\in R\_{\alpha,\Gamma(f)}$. 


Write $f\circ \alpha = Q(h^{(r,s)})$ where $Q$ is a rational function with rational coefficients. Here $(r,s)$ ranges over some finite set of representatives. 


We have $A\alpha B=M$ for some $A,B\in \Gamma(f)$; thus
$$f\circ M=f\circ \alpha \circ B = Q(h^{(r,s)B}).$$


Let $D = \begin{pmatrix}1 & 0\\0& d\end{pmatrix}$. Then 
$$(f\circ M)^{\sigma\_d}= Q(h^{(r,s)BD})=Q(h^{(r,s)DB'}),$$ 
where $B'=D^{-1}BD$ lies in $\Gamma(f)$ by above discussion. Therefore
$$(f\circ M)^{\sigma\_d}=Q(h^{(r,s)D}\circ B').$$
On the other hand, $(f\circ \alpha)^{\sigma\_d}= Q(h^{(r,s)D})$, so $(f\circ M)^{\sigma\_d}=(f\circ \alpha)^{\sigma\_d}\circ B'$. Now we use the fact that $f\circ\alpha$ has rational Fourier coefficients to deduce that $(f\circ M)^{\sigma\_d}=f\circ \alpha\circ B'$. Thus we can take $M' = \alpha B'$.


For the Fricke functions see Shimura: An introduction to the theory of automorphic functions, Section 6.2.



Galois theory of modular functions
**EDIT**. The answer is yes as soon as $f$ and $f \circ \alpha$ both have rational Fourier coefficients.


To see this, we recall Shimura's theorem: for any modular form $f$ of level $N$, any $g \in \mathrm{SL}\_2(\mathbb{Z})$ and any $\sigma \in \mathrm{Aut}(\mathbb{C})$, we have $(f | g)^\sigma = f^\sigma | g\_\lambda$ where $g\_\lambda \in \mathrm{SL}\_2(\mathbb{Z})$ is any lift of the matrix $\begin{pmatrix} 1 & 0 \\ 0 & \lambda \end{pmatrix}^{-1} g \begin{pmatrix} 1 & 0 \\ 0 & \lambda \end{pmatrix} \in \mathrm{SL}\_2(\mathbb{Z}/N\mathbb{Z})$, and $\lambda$ is defined by $\sigma(e^{2\pi i/N})=e^{2\pi i\lambda/N}$. See the comments below for the precise reference.


Note that $g \to g\_\lambda$ defines an action of $(\mathbb{Z}/N\mathbb{Z})^\times$ on $\mathrm{SL}\_2(\mathbb{Z}/N\mathbb{Z})$. Shimura's theorem implies immediately the following.


**Lemma**. Let $f$ be a modular function (or modular form) of level $\Gamma(N)$ with rational Fourier coefficients. Then the stabilizer $\Gamma(f)$ of $f$ in $\mathrm{SL}\_2(\mathbb{Z}/N\mathbb{Z})$ is stable under the action of $(\mathbb{Z}/N\mathbb{Z})^\times$ defined above.


Now, let $\alpha \in M\_2(\mathbb{Z})$ be any matrix with positive determinant, and assume that $f \circ \alpha$ has rational Fourier coefficients. The function $f \circ \alpha$ is modular of some level $N'$ divisible by $N$. We want to show that the polynomial $P\_{f,\alpha}$ defined by (1) has coefficients in $\mathbb{Q}(f)$. For this, it is enough to show that the set of roots of $P\_{f,\alpha}$ is stable by $\mathrm{Aut}(\mathbb{C})$. So let $M$ be any matrix in $\Gamma(f) \alpha \Gamma(f)$, which we write $M=\gamma' \alpha \gamma$. Then
\begin{equation\*}
(f|M)^\sigma = (f | \alpha \gamma)^\sigma = (f \circ \alpha)^\sigma | \gamma\_{\lambda'} = f | \alpha \gamma\_{\lambda'}
\end{equation\*}
for some $\lambda' \in (\mathbb{Z}/N'\mathbb{Z})^\times$. By the lemma above applied in level $N'$, the matrix $\gamma\_{\lambda'}$ belongs to $\Gamma(f)$, which finishes the proof.




---


In general however, this is not always true. For example, take a modular function $f$ of level $N$ with rational Fourier coefficients and $\Gamma(f)=\{\pm I\}$. Such an $f$ exists: the modular curve $Y(N)(\mathbb{C}) = \Gamma(N) \backslash \mathcal{H}$ can be defined over $\mathbb{Q}$, so we have an extension of function fields $\mathbb{Q}(Y(N))/\mathbb{Q}(j)$ with Galois group $\mathrm{PSL}\_2(\mathbb{Z}/N\mathbb{Z})$, then we can take any $f$ generating this extension.


Take $m=1$ and let $\alpha$ be any matrix in $\mathrm{PSL}\_2(\mathbb{Z}/N\mathbb{Z})$. Note that $R\_{\alpha,\Gamma\_f} = \Gamma(N) \alpha$, so we simply have $P\_{f,\alpha}(X)=X-f \circ \alpha$.


In general $f \circ \alpha$ will not have rational Fourier coefficients. In fact, a theorem of Shimura tells us that for any $\sigma \in \mathrm{Aut}(\mathbb{C})$, we have $(f \circ \alpha)^\sigma = f^\sigma \circ \alpha\_\sigma$ where $\alpha\_\sigma = \begin{pmatrix} 1 & 0 \\ 0 & \chi(\sigma) \end{pmatrix}^{-1} \alpha \begin{pmatrix} 1 & 0 \\ 0 & \chi(\sigma) \end{pmatrix}$ and $\chi(\sigma) \in (\mathbb{Z}/N\mathbb{Z})^\times$ is the cyclotomic character, defined by $\sigma(e^{2\pi i/N})=e^{2\pi i \chi(\sigma)/N}$. See for example [this MO answer](https://mathoverflow.net/a/280808/6506).


In general however, it seems that you are asking whether the Hecke operator $T\_\alpha =\Gamma(f) \alpha \Gamma(f)$ is defined over $\mathbb{Q}$. Maybe there will still be a relation of the form $T\_\alpha \circ \sigma = \sigma \circ T\_{\alpha'}$ at least when $m$ is prime to $N$ (this is just a guess, I have to check). In any case, this kind of property is more naturally stated using the adelic language: you take a compact open subgroup $K$ of $\mathrm{GL}\_2(\hat{\mathbb{Z}})$ and consider the Hecke correspondence $T\_\alpha = K\alpha K$ where $\alpha$ is any matrix in $\mathrm{GL}\_2(\mathbb{A}\_f)$, here $\mathbb{A}\_f = \hat{\mathbb{Z}} \otimes \mathbb{Q}$ are the finite adeles of $\mathbb{Q}$. Then the Galois action will essentially correspond to the determinant of $\alpha$ via abelian class field theory.


