A PDE-Constrained Optimization Approach to Uncertainty Quantification in Inverse Problems, with Applications to Inverse Scattering