Mathematically the data of the topology is encoded in the structure of the operators themselves. I will focus on the simple case of the punctured plane $M=\mathbb{R}^2\setminus \{0\}$.
Suppose we are considering all $U(1)$-bundles with flat connections on $M$.
From minimal-coupling, we have that $p_i = (D_A)_i$ where $A$ is our flat connection. $[p_i,p_j]=0$ and $[q_i, p_j]=i\delta_{ij}$. Thus we have some representation of the canonical commutation relations.
Note: The Stone-Von Neumann theorem does not apply here! In particular it is crucial that the Weyl relations, which are the relations actually relevant to Stone-Von-Neumann, may not necessarily hold thanks to the nontrivial topological structure of the problem
Call this representation $\pi_A$. One can prove that $\pi_A\cong \pi_{CCR}$ if and only if the holonomy $\int_{C_1} A \cdot dl \in 2\pi\mathbb{Z}$.
In more generality, you can prove that $\pi_A \cong \pi_{A'}$ if and only if $A$ and $A'$ are gauge-equivalent.
A nice discussion of this framework is in Inequivalent Representations of Canonical Commutation and Anti-Commutation Relations by Asao Arai
Relating this to topology, notice that the relevant Hilbert space here is $L^2(\mathbb{R}^2\setminus \{0\})\cong L^2(\mathbb{R}^2)$. Thus the Hilbert space alone is completely blind to the distinction between the topologically trivial plane and the punctured plane. Instead it is the Hamiltonian itself having a different form (both in terms of their domains and their literal form).
To highlight how the domain itself plays a role, recall the relatively simple situation of the particle on an interval. Consider $H=-i\Delta$ on $C_c^\infty(0,1)$ in the Hilbert space $L^2(0,1)$. This operator admits many self-adjoint extensions determined entirely by fixing the domain. For example, if you set vanishing boundary conditions at the boundary, you get the classic infinite square well. If you set periodic boundary conditions, you get the particle-on-a-circle Hamiltonian, which you can then interpret as actually describing $M=S^1$.
So you can take a trivializing chart, and your Hilbert space will not see the difference. But the Hamiltonian is going to be some kind of differential operator, and this differential operator is sensitive to the boundary conditions at the boundaries of the domain that indicate whether or not a function is actually smooth, and this carries the information you had lost elsewhere.