Ovintiv Inc. agreed to buy NuVista Energy Ltd in a deal valued at about $2.7 billion that expands the shale explorer’s operations in Canada.