In a medium bowl, whisk together the egg yolks and sugar until smooth and creamy. Place the mixture over a double boiler and whisk constantly for about 5-7 minutes until thickened. Remove from heat and let it cool slightly.
Once cooled, gently fold in the mascarpone cheese until fully combined and smooth.
In a separate bowl, whip the heavy cream and vanilla extract until stiff peaks form. Carefully fold the whipped cream into the mascarpone mixture.
In a shallow dish, mix the cooled espresso with the rum or coffee liqueur if using.
Quickly dip each ladyfinger into the espresso mixture and place them in a single layer at the bottom of a 9x9-inch dish or a similarly sized serving dish.
Spread half of the mascarpone mixture over the soaked ladyfingers. Repeat with another layer of dipped ladyfingers, followed by the remaining mascarpone mixture.
Cover and refrigerate for at least 4 hours or overnight to set. Before serving, dust the top with cocoa powder and garnish with dark chocolate shavings if desired.