Set a fine-mesh sieve over a medium bowl. In a medium saucepan, whisk together the sugar, cornstarch, cocoa, and salt. Gradually whisk in the milk, then the egg yolks.
Cook the milk mixture over medium heat, whisking constantly, until thickened to the consistency of mayonnaise, 7 to 8 minutes. Continue to cook, whisking, for 1 minute more. Remove from heat and pour through the sieve into the bowl, pushing the mixture through gently with a rubber spatula or spoon. Add the butter and chocolate and stir until melted. Mix in the vanilla.
Press a piece of plastic wrap directly on the surface of the pudding and refrigerate for at least 2 hours and up to 2 days. Before serving, gently stir the pudding to loosen it. Serve with the whipped cream.