Let $a$ and $b$ respectively be half the lengths of the major and minor axes of the ellipse.
Let $A$ and $B$ respectively be half the lengths of the transverse and conjugate axes of the hyperbola.
Let $f$ be half the distance between the foci, which are the same points for both the ellipse and the hyperbola. Then
\begin{align}
a^2 &= f^2 + b^2, \\
A^2 &= f^2 - B^2,
\end{align}
which implies that $a > f$ and $B < f.$
(All distance measurements are non-negative.)
The equation of the ellipse is
$$ \frac{x^2}{a^2} + \frac{y^2}{b^2} - 1 = 0 \tag1 $$
and the equation of the hyperbola is
$$ \frac{x^2}{A^2} - \frac{y^2}{B^2} - 1 = 0. \tag2 $$
The desired curve satisfies Equation $(1)$ when
$\frac{x^2}{A^2} - \frac{y^2}{B^2} < 1$
and satisfies Equation $(2)$ when $\frac{x^2}{a^2} + \frac{y^2}{b^2} < 1.$
Inspired by the clever solution in
another answer,
we may try to unify the two equations by first setting the $x^2$ terms equal.
For the ellipse we get
$$ x^2 + \frac{a^2}{b^2} y^2 - a^2 = 0 \tag3$$
and for the hyperbola
$$ x^2 - \frac{A^2}{B^2} y^2 - A^2 = 0. \tag4$$
The "average" of these equations (taking half the sum of the left-hand sides of $(3)$ and $(4)$) is
$$ x^2 + \frac12\left(\frac{a^2}{b^2} - \frac{A^2}{B^2}\right) y^2
- \frac12 (a^2 + A^2) = 0 \tag5$$
and "half the difference" of these equations (taking half the difference of the left-hand sides of $(3)$ and $(4)$) is
$$ \frac12\left(\frac{a^2}{b^2} + \frac{A^2}{B^2}\right) y^2
- \frac12 (a^2 - A^2) = 0. \tag6$$
Equation $(3)$ is then the "sum" of Equations $(5)$ and $(6)$ and Equation $(4)$ is the "difference", subtracting $(6)$ from $(5).$
But if we add the absolute value of the left side of $(6)$ to the left side of $(5)$, we get
\begin{multline}
\qquad
x^2 + \frac12\left(\frac{a^2}{b^2} - \frac{A^2}{B^2}\right) y^2
- \frac12 (a^2 + A^2) \\
+ \left\lvert \frac12\left(\frac{a^2}{b^2} + \frac{A^2}{B^2}\right) y^2
- \frac12 (a^2 - A^2) \right\rvert = 0 \qquad \tag7
\end{multline}
Observe that when
$\left(\frac{a^2}{b^2} + \frac{A^2}{B^2}\right) y^2 \geq (a^2 - A^2)$,
Equation $(7)$ matches Equation $(5)$ and therefore follows the path of the ellipse, but when
$\left(\frac{a^2}{b^2} + \frac{A^2}{B^2}\right) y^2 \leq (a^2 - A^2)$,
Equation $(7)$ matches Equation $(6)$ and therefore follows the path of the hyperbola.
When $\left(\frac{a^2}{b^2} + \frac{A^2}{B^2}\right) y^2 = (a^2 - A^2)$,
Equation $(7)$ matches both $(5)$ and $(6)$ simultaneously and it determines
the intersections of the ellipse and hyperbola.
That is, this is exactly the equation we want when the two foci are on the $x$ axis and are equidistant from the origin.
Note that since $a$ is a function of $f$ and $b$ and since $A$ is a function of $f$ and $B$, we can express the two equations using just three variables
(and should do so, in order to ensure the same foci):
$f$, $a$, and $A$; $f$, $b$, and $B$; or some other combination of three of the five variables. As long as we choose three mutually independent variables we can set them to whichever values we like (under the constraints $a > f$ and $B < f$) and derive the other two.
For example, we could choose the length and width of the ellipse ($2a$ and $2b$) and the distance $2A$ between the vertices of the hyperbola,
under the constraint that $A^2 < a^2 - b^2.$
If we choose $f,$ $b,$ and $B$ such that $b^2 = 1 + \sqrt{f^2 + 1}$ and
$B^2 = b^2 - 2,$ then Equation $(7)$ becomes
$$
x^2 + \left(\sqrt{f^2 +1}\right) \left\lvert y^2 - 1\right\rvert - (f^2 + 1) = 0,
$$
the same equation found in
the answer that inspired this one.
For a curve at any other location and orientation in the plane, we can replace $x$ and $y$ with linear combinations of $x$ and $y$ that translate and rotate the figure as required.
We then get an equation in which the sum of one quadratic polynomial in $x$ and $y$
and the absolute value of another quadratic polynomial in $x$ and $y$ is equal to zero.