In a medium-sized saucepan, thoroughly combine the granulated sugar, cocoa powder, and cornstarch using a whisk until no clumps remain.
In a separate container, beat the egg yolks with the milk until fully incorporated. Add this mixture into the saucepan along with the butter pieces.
Place the saucepan over medium heat and cook, stirring frequently with a whisk, until the mixture thickens to a smooth, pudding-like consistency.
Remove the pan from heat. Stir in the salt and vanilla extract until well blended. If the texture is not completely smooth, beat with an electric mixer to eliminate any remaining lumps.
Transfer the warm chocolate filling into the prepared baked pie crust. Smooth the top and refrigerate for a minimum of 3 hours until fully set.
Before serving, optionally garnish the chilled pie with a layer of whipped cream or meringue, prepared as outlined below.