1. In a medium saucepan over medium-low heat, bring cream, espresso beans and milk just to a boil. Remove from heat and let stand for 1 hour. Strain into a bowl and set aside.
2. In a separate bowl, whisk egg yolks with sugar until thickened and pale yellow. Set aside.
3. Return cream mixture to the saucepan. Bring to a simmer over medium-low heat. Gradually whisk into the egg mixture.
4.Return entire mixture to the saucepan. Cook over low heat, stirring constantly, until the mixture is thick enough to coat the back of a wooden spoon. Be careful not to let it boil. Strain into a clean large bowl. Let cool to room temperature.
5. Stir in melted chocoalte. Cover and refrigerate until completely cold or overnight.
6. Stir cream mixture. Transfer to an ice cream maker and freeze according to manufacturer's instructions. Add coffee-flavored liqueur, if using, in the last 5 minutes of freezing and let machine stir it in.