The closest solution i can find comes from Hale’s (1994) Introduction to spaceflight, wherein chapter 9 discusses range equations for such ballistic bodies. He derives an equation
$$cot(\frac{\Psi}{2})=\frac{2}{Q_{bo}}csc(2\phi_{bo}) - cot(\phi_{bo})$$
where
$$Q_{bo}=\frac{V_{bo}^2r_{bo}}{\mu}$$
is a dimensionless quantity that is roughly measures twice the ratio of kinetic to potential energy at the burnout point (subscript “bo”). $\mu$ is the standard gravitational parameter and $\Psi$ is the range angle and $\phi_{bo}$ is the launch angle.
What you want is to have $\Phi=90^0$ and $r_{bo}=$ the radius of mars. Then you can play with the burnout velocity and launch angle until you get a feasible solution. Note that even though many launch angle will give a burnout velocity, some of the are infeasible because they rely on the orbit traversing through the interior of the planet.
Keep in mind that this equation is based on a lot of simplifying assumptions: non rotating earth, no atmosphere, a spherical planet, symmetrical trajectory, and a an insignificant freefall range.