The resulting object will be (assuming everything's compact, say...) an orientable manifold, but not an oriented one. If you want it to be oriented, with the orientation matching that of $M_1$, say, then the map $f$ should be orientation reversing (which may not be possible without reversing the orientation on $M_2$, and hence the induced orientation on $\partial M_2$).
If you think hard about two unit disks in the plane, joined to make a sphere, you'll see what I mean.
post-comment edits
A manifold $M$ is a topological space $X$ together with a (maximal) atlas $A$ that satisfies certain rules that are well-known to the questioner, so I won't write them out. An oriented manifold is the same thing, together with a subset $S$ of the atlas that consists of charts that are declared to be "orientation preserving" (and which, when they have overlapping domains, satisfy something that's the equivalent (in the smooth case) of the transition function's derivative having positive determinant on the overlap).
To any oriented manifold, $(X, A, S)$ there's an associated manifold $(X, A)$ gotten by ignoring the orientation.
If we glue oriented manifolds $M_1$ and $M_2$ together as in the question and if their boundaries are each connected and $f$ is an orientation-reversing homeomorphism between them, then $M = M_1 \cup_f M_2$ is orientable, and indeed, the orientation can be made consistent with that of $M_1$ and $M_2$, in the sense that both $M_1$ and $M_2$ are embedded in $M$, and the embeddings are orientation-preserving. The glued up manifold is orientable, but until we pick an orientation, it's just a manifold! And the homeomorphism class of that manifold is independent of the orientations of $M_1$ and $M_2$. That's the claim that Michael Albanese, in the comments, seems willing to believe. Let's look at the orientation preserving case now.
If $f$ happens to be orientation-preserving, then we can reverse the orientation on $M_2$ to get a different oriented manifold, $M_2'$, and a map $f' : \partial M_1 \to \partial M_2': x \mapsto f(x)$ which is exactly the same as $f$, except that the target oriented-manifold is now $M_2$ with the other orientation. Note, too, that $M_2'$ and $M_2$ are homeomorphic as manifolds, by the identity map, but are not necessarily homeomorphic by an orientation-preserving homeomorphism.
If we now build $M' = M_1 \cup_{f'} M_2'$, it's homeomorphic to $M$, but not necessarily oriented-homeomorphic. It's orientable, and with the right orientation, we find that $M_1$ and $M_2'$ are both embedded in it by orientation-preserving embeddings.
On the other hand, it's not true that $M_2$ is embedded in it by an orientation-preserving embedding.
What IS true is that $M_2$ is embedded in it as a topological submanifold-with-boundary.
In the case Michael asked about, where $\partial M_1 = \partial M_2 = S^3$, and $M_1$ and $M_2$ are both $\Bbb CP^2$, we get that
$$
M' = \Bbb CP^2 \# \overline{\Bbb CP^2}
$$
where the "equality" here is an orientation-preserving homeomorphism (basically just "inclusion"). But it's also true that $M'$ is homeomorphic (again by inclusion) to
$\Bbb CP^2 \# \Bbb CP^2$, by a non-orientation-preserving homeomorphism.
Best Answer
You appear to be missing a point-set theoretic tool to do with the quotient topology.
Let's build a space by taking two spaces $X$ and $Y$, take their disjoint union, then identify a subset of $X$ with a subset of $Y$ via a homeomorphism. Let's say $A \subset X$ and $B \subset Y$ and $\phi : A \to B$ is a homeomorphism.
$$X \sqcup_\phi Y := (X \sqcup Y) / \sim$$
where the equivalence relation $\sim$ is generated by $a \in A$ is equivalent to $\phi(a) \in B$.
Easy-to-prove-fact: (1) If $\psi : Y \to Y$ is a homeomorphism such that $\psi(B) = B$, then there is a homeomorphism $X \sqcup_\phi Y \to X \sqcup_{\psi \circ \phi} Y$. The map is defined to be the identity on $X$, and $\psi$ on $Y$.
(2) If $\eta : X \to X$ is a homeomorphism such that $\eta(A) = A$, then there is a homeomorphism $X\sqcup_\phi Y \to X \sqcup_{\phi \circ \eta} Y$. The map is the identity on $Y$ and $\eta^{-1}$ on $X$.
In your case, $X=Y = S^1 \times D^2$ and $A=B=S^1 \times S^1$. $\pi_0 Homeo(S^1 \times S^1) \simeq GL_2(\mathbb Z)$ and $\pi_0 Homeo(S^1 \times D^2) \simeq \mathbb Z_2 \times \mathbb Z_2 \times \mathbb Z$, the solid torus has a mirror reflection, you can reverse the orientation of the core and you can "twist" about it.
From this perspective, the manifolds you can generate by gluing two solid tori together are controlled by the double cosets of $\pi_0 Homeo(S^1 \times D^2)$ in $\pi_0 Homeo(S^1 \times S^1)$. Using only cosets of one type tells you this reduces to studying where the meridian goes.
A less dry argument would be to first ask where the meridian goes, and then simply observe that, once you know where the meridian goes, any two extensions of the meridian embedding to a diffeomorphism of $S^1 \times S^1$ must differ by a diffeomorphism of $S^1 \times D^2$. So here you're using some actual knowledge of the surface.