Preheat the oven to 350°F. Line a standard muffin pan with paper baking cups.
In a medium bowl, whisk together the gluten-free flour, cocoa powder, baking soda, baking powder, espresso powder (if using) and salt.
Add the sugar, oil, eggs, sour cream and vanilla to the bowl of a stand mixer or a hand mixer. Mix on medium-high speed until well-combined.
With the mixer running on low, slowly add the dry ingredients in 3 additions, mixing after each addition.
Slowly pour in the hot water. Mix on medium speed for 2-3 minutes, scraping down the sides and bottom of the bowl halfway through, until smooth and incorporated.
Using a kitchen scoop or large spoon, portion the batter evenly into the prepared baking cups. Bake for 18-20 minutes, until a toothpick inserted in the center comes out mostly clean with a few moist crumbs.
Let the cupcakes cool in their pan for 5 minutes, then transfer to a wire rack to cool completely.
For the frosting: In the bowl of a stand mixer, or using a hand mixer, beat the butter on medium-high speed until creamy, about 2 minutes. Add 3 cups powdered sugar along with the cocoa powder, cream/milk, vanilla extract, almond extract and salt. Mix on low speed for 30 seconds, then increase to medium-high speed and whip for a full 2 minutes.
If the frosting is too thick, add a little more cream/milk. If the frosting is too thin, add more powdered sugar to make a spreadable consistency. Frost the cupcakes as desired.