Brew the coffee, stir in the liqueur if using, and pour it into a shallow dish. Let it cool completely.
Bring about 1 inch of water to a bare simmer in a medium saucepan. In a heatproof bowl, combine the egg yolks, sugar, and milk. Set the bowl over the pan without touching the water and whisk constantly for 6 to 8 minutes, until thick, pale, and falling from the whisk in a slow ribbon, and an instant-read thermometer reads 160°F.
Remove the bowl from the heat, whisk for 1 more minute, and let the mixture cool to room temperature, about 15 minutes.
Add the cold mascarpone to the cooled yolk mixture and stir or beat on low just until smooth. Do not overmix.
In a separate bowl, whip the heavy cream and vanilla to stiff peaks. Gently fold the whipped cream into the mascarpone mixture in two additions.
Dip each ladyfinger into the coffee for about 1 second per side and arrange a snug single layer (about 20) in a 9x13-inch dish, breaking a few to fill gaps. Spread half of the cream over the top.
Repeat with a second layer of dipped ladyfingers and the remaining cream. Smooth the top.
Cover and refrigerate for at least 6 hours, or overnight. Just before serving, dust with cocoa powder through a fine-mesh strainer and top with shaved chocolate if desired.