A Canadian court has ruled in favor of Tesla Inc after the electric carmaker challenged the province of Ontario’s wind-down of an electric vehicle rebate.