An Optimal and Scalable Matrix Mechanism for Noisy Marginals under Convex Loss Functions