The path integral of 3D gravity near extremality; or, JT gravity with defects as a matrix integral