In a medium bowl, sift the powdered sugar with the salt and set aside. In a separate small bowl, whisk the cocoa with 1 1/2 tablespoons of the milk and the espresso powder (if using) to form a smooth, glossy paste; let cool 5 minutes.
Beat the softened butter in a stand mixer fitted with the paddle (or with a hand mixer) on medium-high speed until pale and fluffy, 2 to 3 minutes. Scrape the bowl.
Mix in the vanilla and the cooled cocoa paste until fully blended and uniformly dark, about 1 minute on medium speed.
Add the cream cheese in 4 pieces. Beat on low just to combine, then increase to medium for 45 to 60 seconds until smooth and creamy. Avoid overbeating once the cream cheese is added to keep the frosting sturdy.
Add the sifted powdered sugar in three additions, mixing on low after each until nearly incorporated. Drizzle in the remaining 1 1/2 tablespoons milk as needed for a creamy, spreadable consistency.
Increase to medium speed and beat 30 to 60 seconds until light and smooth. Finish by mixing on low for 20 to 30 seconds to knock out excess air bubbles.
If the frosting seems soft, chill it for 10 to 15 minutes, then stir before using. If it’s too thick, add milk 1 teaspoon at a time. Spread or pipe onto completely cooled cakes or cupcakes.
Store covered in the refrigerator for up to 5 days. Bring to room temperature and re-whip briefly before using again.