A Canadian court ruled on Friday that a federal carbon-pricing plan does not violate the constitution, marking a victory for Prime Minister Justin Trudeau’s government.