Suppose we are given non-negative integers $b_0, b_1, \dots, b_n$ with $b_k = b_{n-k}$. Is there a closed orientable manifold $M$ with $b_i(M) = b_i$? First we need $b_0 = b_n \geq 1$. It is enough to answer the question with $b_0 = b_n = 1$ as we can then just take the disjoint union with the appropriate number of spheres. So from now on, $b_0 = b_n = 1$.

If $n = 2m + 1$, then there is a closed smooth orientable manifold $M$ with $b_i(M) = b_i$, namely

$$M = b_1(S^1\times S^{n-1})\ \#\ \dots\ \#\ b_m(S^m\times S^{m+1}).$$

If $n = 2m$ and $b_m$ is even, then there is a closed smooth orientable manifold $M$ with $b_i(M) = b_i$, namely

$$M = b_1(S^1\times S^{n-1})\ \#\ \dots\ \#\ b_{m-1}(S^{m-1}\times S^{m+1})\ \#\ \tfrac{b_m}{2}(S^m\times S^m).$$

Suppose now that $n = 2m$ and $b_m$ is odd. If $m$ is odd, then there is no manifold realising these Betti numbers: the intersection form on the middle dimension is a non-degenerate skew-symmetric form, so the middle Betti number is necessarily even. If $m$ is even, things are more complicated. First of all, such examples can exist, e.g. $\mathbb{CP}^2$. However, the above approach of taking connected sums of products of spheres can't work because the resulting manifolds are all nullcobordant, but a manifold with such Betti numbers is not: $b_m(M)$ and $\sigma(M)$ have the same parity and $\sigma(M)$ is a cobordism invariant.

Note that a closed smooth orientable $2m$-dimensional manifold with Betti numbers $b_0 = b_m = b_n = 1$ and all others zero has rational cohomology ring $\mathbb{Q}[\alpha]/(\alpha^3)$ where $\deg\alpha = m$. For this reason, call such a manifold a *rational projective plane* and denote it by $\mathbb{QP}^2$. If such a manifold exists in dimension $n$, then if $b_m$ is odd, there is a closed smooth orientable manifold $M$ with $b_i(M) = b_i$, namely

$$M = b_1(S^1\times S^{n-1})\ \#\ \dots\ \#\ b_{m-1}(S^{m-1}\times S^{m+1})\ \#\ \tfrac{b_m-1}{2}(S^m\times S^m)\ \# \mathbb{QP}^2.$$

So the natural question to ask is:

For which $n$ does there exist a rational projective plane?

Well, we have $\mathbb{CP}^2$, $\mathbb{HP}^2$ and $\mathbb{OP}^2$ which are actually simply connected and have integral cohomology ring $\mathbb{Z}[\alpha]/(\alpha^3)$; by the solution of the Hopf invariant one problem, these are the only such manifolds up to homotopy equivalence.

In Smooth manifolds with prescribed rational cohomology ring, Fowler and Su show (Theorem A) that for $n \geq 8$, a rational projective plane can only exist in dimensions of the form $n = 8(2^a + 2^b)$ for some non-negative integers $a$ and $b$.^{1} In Rational analogs of projective planes, Su shows (Theorem 1.1) the existence of a (simply-connected) rational projective plane in dimension $32$. Later, Kennard and Su also proved the existence of (simply-connected) rational projective planes in dimensions $128$ and $256$, see On dimensions supporting a rational projective plane, Theorem 1.1. The paper also contains non-existence results for simply-connected rational projective planes in certain dimensions.^{2}

It may seem that the lack of a projective plane in a given dimension prevents the realisability of any collection of Betti numbers with middle Betti number odd, but that is not true. For example, when $m$ is even, $\mathbb{CP}^m$ has $b_m = 1$ regardless of whether or not a rational projective plane exists (thanks to Will Sawin for pointing this out). That is, the question of realisability of Betti numbers does not reduce to the existence of rational projective planes, it is much more complicated.

Finally, it is worth noting that if $n = 2m = 4l$ and $b_{4j} \geq 1$ for $j = 1, \dots, l - 1$ and $b_m$ is odd, then there is a closed smooth orientable manifold $M$ with $b_i(M) = b_i$, namely

$$M = b_1'(S^1\times S^{n-1})\ \#\ \dots \# \ b_{m-1}'(S^{m-1}\times S^{m+1})\ \#\ \tfrac{b_m'}{2}(S^m\times S^m)\ \#\ \mathbb{HP}^l$$

where $b_{4j}' = b_{4j} - 1$ for $j = 1, \dots, l - 1$ and $b_i' = b_i$ otherwise.

^{1} _{The definition of rational projective plane in that paper includes the hypothesis of being simply connected. However, the proof of Theorem A does not use this property, so the result holds for the definition used above.}

^{2} _{I don't know the proof of these results, so I'm not sure if the simply connected hypothesis can be removed.}