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, assuming an impulse thrust at the planet’s surface. 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, not all will. Even so, some of the solutions are infeasible because they may, for example, 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.