Prepare the Ice Bath: Fill a large bowl about halfway with ice and add cold water until it reaches roughly two-thirds full. Place a second, clean bowl on top, creating a double boiler-like setup for cooling your custard later.
Melt the Chocolate: Set a heatproof bowl over a pot of simmering water (double boiler). Add the chopped chocolate and stir frequently until it is completely melted and smooth. Remove from heat and wipe the bowl’s bottom to prevent water droplets from falling into your ice cream base.
Heat the Dairy and Cocoa Mixture: In a 3-quart saucepan, combine the whole milk, heavy cream, half of the sugar, cocoa powder, and espresso powder if using. Warm over medium-low heat, stirring occasionally, until the sugar dissolves and the mixture just starts to simmer. Remove from heat and let it rest for a minute.
Whisk Egg Yolks and Sugar: In a separate bowl, vigorously whisk the egg yolks with the remaining sugar until the mixture becomes thick, pale yellow, and ribbons form when the whisk is lifted. Using an electric mixer is fine if preferred.
Temper the Eggs: Slowly pour half of the hot cocoa mixture into the yolk mixture, whisking constantly to avoid scrambling the eggs. Then transfer this combined mixture back to the saucepan with the remaining dairy mixture.
Cook the Custard: Return the saucepan to low heat and stir continuously with a wooden spoon until the mixture thickens enough to coat the back of the spoon and reaches 185°F (85°C). This should take just a few minutes. Remove from heat immediately to avoid curdling.
Incorporate Chocolate and Flavorings: Whisk in the melted chocolate, vanilla extract, and salt until the mixture is smooth and fully combined.
Chill the Custard: Pour the custard through a fine mesh strainer into the ice bath setup prepared earlier. Stir occasionally to speed cooling. Once the custard is cold (about 10 minutes), cover the surface directly with plastic wrap and refrigerate for at least 4 hours or overnight to develop flavor and texture.
Prepare Peanut Butter Swirl: While the custard chills, whisk together peanut butter, heavy cream, and a pinch of salt in a small bowl until creamy and smooth.
Churn the Ice Cream: Following your ice cream maker’s instructions, churn the chilled custard until it reaches a soft-serve consistency.
Add Peanut Butter Swirl and Freeze: Transfer the churned ice cream to a freezer-safe container. Add dollops of the peanut butter mixture intermittently, swirling gently with a spatula to create a marbled effect. Cover the container tightly and freeze until firm, at least 4 hours.