Quantum Algorithms for Weighted Constrained Sampling and Weighted Model Counting