A necessary optimality condition for the minimum-drag shape for a non-magnetic solid body immersed in the uniform flow of an electrically conducting viscous incompressible fluid under the presence of a magnetic field is obtained. It is assumed that the flow and magnetic field are uniform and parallel at infinity, and that the body and fluid have the same magnetic permeability. The condition is derived based on the linearized magnetohydrodynamic (MHD) equations subject to a constraint on the body's volume, and generalizes the existing optimality conditions for the minimum-drag shapes for the body in the Stokes and Oseen flows of a non-conducting fluid. It is shown that for any Hartmann number M, Reynolds number Re and magnetic Reynolds number Re(m), the minimum-drag shapes are fore-and-aft symmetric and have conic vertices with an angle of 2 pi/3. The minimum-drag shapes are represented in a function-series form, and the series coefficients are found iteratively with the derived optimality condition. At each iteration, the MHD problem is solved via the boundary integral equations obtained based on the Cauchy integral formula for generalized analytic functions. With respect to the equal-volume sphere, drag reduction as a function of the Cowling number S = M(2)/(Re(m) Re) is smallest at S = 1. Also, in the considered examples, the drag values for the minimum-drag shapes and equal-volume minimum-drag spheroids are sufficiently close.