Pour 1 1/2 cups milk into a medium saucepan and heat over medium until the milk is hot and steaming and small bubbles form at the edges (do not boil).
In a bowl, whisk together 1/2 cup sugar, 3 tablespoons cocoa powder, 3 tablespoons all-purpose flour, and 1/4 teaspoon salt until evenly combined.
Gradually whisk the dry mixture into the hot milk in the saucepan until smooth. Return the pan to medium heat and cook, stirring constantly, until the mixture thickens.
Remove the pan briefly from the heat. In a separate bowl have the 2 egg yolks, beaten. Add a small amount of the hot chocolate mixture to the beaten yolks while whisking constantly to temper them, then pour the tempered yolks back into the saucepan, stirring constantly.
Return the pan to medium heat and cook, stirring constantly, for at least two minutes more, until the mixture is thick and smooth.
Remove from heat and stir in 1 teaspoon vanilla extract.
Pour the chocolate pudding into the baked pie shell and smooth the top. Let the pie cool to room temperature, then refrigerate until fully chilled and set.
When the chocolate filling is cooled and set, top with Cool Whip or whipped cream before serving.