I think I understand the construction for $H^2(M)$ when $H_1(M, \mathbb{Z})=0$ and can make it more explicit than the other answers. As I noted in a comment above, when $H_1(M, \mathbb{Z})$ has torsion, we cannot hope for a canonical construction. When $H_1(M, \mathbb{Z})$ is torsion-free but nontrivial, there should be a construction, but I haven't found it. Also, I am terrible with functional analysis and infinite dimensional spaces so I will be vague about what "nice" means.
Let $\omega$ be a closed integral $2$-form on $M$. Let $\gamma$ be a closed path in $M$. Since $H_1(M)=0$, there is a surface $S$ with $\partial S = \gamma$. Define $\theta(\gamma) = \exp(2 \pi i \int_S \omega)$. We must check that this is independent of the choice of $S$: If $\partial S_1 = \partial S_2$ then $S_1 - S_2$ is a cycle in $H_2(M, \mathbb{Z})$ so $\int_{S_1-S_2} \omega \in \mathbb{Z}$ and we deduce that $\int_{S_1} \omega \equiv \int_{S_2} \omega \bmod \mathbb{Z}$.
Fix a base point $x_0$ in $M$. Let $T$ be the space of all nice paths in $M$ starting at $x_0$. If you fear infinite dimensional spaces more than you hate making choices, choose a metric on $M$, let $T$ be the tangent space to $M$ at $x_0$ and interpret "nice" as "geodesic"; by the Hopf-Rinow theorem, we can identify these with $M$. (I can't decide whether my hatred or my fear is greater.)
Let $V$ be the vector space of all nice functions $f:T \to \mathbb{C}$ with the property that, if $\gamma_1$ and $\gamma_2$ are two paths $x_0 \leadsto x_1$ then $f(\gamma_1) = \theta(\gamma_1-\gamma_2) f(\gamma_2)$. (If $T$ is the tangent space to $M$ at $x$, I think we can take "nice" to be "smooth".)
Any path $\gamma$ now gives a linear functional $V \to \mathbb{C}$ by $f \mapsto
f(\gamma)$. If $\gamma_1$ and $\gamma_2$ both have endpoint $x_1$, then the corresponding linear functionals are proportional. So each $x \in M$ defines a point in $\mathbb{P}(V^{\ast})$. Up to the question of how to put a smooth structure on $\mathbb{P}(V^{\ast})$, we have embedded $M$ into an infinite dimensional projective space.
Again, if you fear infinite dimensional spaces more than you hate choices, rather than working with all of $V$, choose a finite dimensional subspace such that, for any $x \in M$, there is some $f \in V$ which is nonzero at $x$. We could try doing something like restricting ourselves to harmonic functions $f$ in the hope of getting a canonical finite dimensional subspace, but then we would get into the question of what the analogue of "ample" is in this setting. I don't know, but maybe some differential geometer does.
This was the result of composing two tricks. The second trick is familiar to algebraic geometers: If $L$ is a vector bundle on $X$ and $V$ is its space of global sections, then $X$ embeds, choice-free, into $\mathbb{P}(V^{\ast})$.
The first trick was that, given a line bundle $L$ with connection, I can think of sections of $L$ over $M$ as functions $T \to \mathbb{C}$ whose holonomy respects the holonomy of the connection. I then remembered enough about how curvature works to see that I could write down the holonomy without building the line bundle or the connection.
If $H_1(M)$ is nonzero, define $Z_1(M)$ to be the integer $1$-cycles and $B_1(M)$ the integer $1$-boundaries, so $H_1(M) = Z_1(M)/B_1(M)$. The map $\theta$ still makes sense as a map $B_1(M) \to U(1)$. I think what we are supposed to do is lift $\theta$ to a map $\tilde{\theta}: C_1(M) \to U(1)$. Once we have done that, there is no problem with repeating the above construction with $\tilde{\theta}$. Presumably, there is a theorem that it only matters what choice we make on torsion elements of $C_1(M)/B_1(M)$, but that isn't clear to me.