In a small bowl, whisk together vanilla and espresso powder. Set aside.
In a medium saucepan, whisk together sugar cocoa, cornstarch, and salt. Add egg yolks and cream and whisk until combined. Whisk in milk.
Heat contents of saucepan over medium heat. Cook, stirring constantly, until mixture begins to simmer. Continue to stir until thickened, about 5 to 8 minutes. Heat for 30 seconds longer, then remove pan from heat and add butter and chocolate. Stir until melted and fully incorporated. Add vanilla mixture.
Pour pudding through a fine-mesh strainer into a large serving bowl.
Press lightly greased parchment paper or plastic wrap against surface of pudding to prevent a crust from forming as it cools. Place pudding in the refrigerator to cool for at least 4 hours.
Stir pudding briefly before serving. Garnish with fresh whipped cream and chocolate shavings if desired.