No, you can't do that. The inside of the carton is not cardboard, it is covered with a thin layer of a paraffin-like substance. If you hear the carton to 82 Celsius, you will melt the paraffin into the milk.
There are methods where you heat and ferment in the same container, but I don't like them. With traditional heating, you end up with a layer of milk proteins stick to the bottom. Sous vide somewhat relaxes the problem, but doesn't eliminate it completely. And then there is the skin formed on top during cooling. It's more tender of you do it in a closed container, but it still exists, and pieces of it spread through the container when you stir in the culture. So the yogurt is much better if you put the milk through a sieve after cooling and before adding the culture, and ferment it in a clean container.
The third consideration is that frequently, small containers are more convenient for using the yogurt rather than spinning it out of a big container, where you get contamination and whey buildup. So, it is even better to hear and cool in a large container, but ferment in small containers. So my own preferred method is heating and cooling in one large container, sieving into a second large one where I add the culture, then ladling into individual jars.
To sum it up, a single-container method gives inferior results. If you want to try it, it works, but not with the milk carton. At best, you could buy milk in glass bottles and use the bottle, but you'll have a very hard time getting it out. Better find a different container.