Heat the oven to 350°F. Line a 12-cup muffin pan with paper liners.
Toast the finishing coconut: Place 1/3 cup shredded coconut in a dry skillet over medium heat, stirring constantly until lightly golden, 3–4 minutes. Transfer to a plate to cool completely.
Bloom the cocoa: In a small bowl, whisk the cocoa powder, espresso powder, and hot water into a smooth paste. Let cool 2–3 minutes.
Whisk dry ingredients: In a large bowl, combine flour, sugar, baking soda, baking powder, and salt.
Mix wet ingredients: In a separate bowl or large measuring cup, whisk milk, oil, vinegar, vanilla, and coconut extract. Stir in the cooled cocoa paste until evenly combined.
Make the batter: Pour the wet mixture into the dry ingredients and whisk just until no dry streaks remain. Fold in 2/3 cup shredded coconut. Let the batter rest 5 minutes to hydrate the coconut.
Fill and bake: Divide batter among liners (about 1/4 cup each). Bake 17–19 minutes, rotating the pan once halfway through, until the tops spring back and a toothpick comes out with a few moist crumbs.
Cool completely: Let cupcakes cool in the pan 5 minutes, then transfer to a rack to cool fully before frosting.
Make the coconut buttercream: In a stand mixer or with a hand mixer, beat the softened butter on medium-high until very creamy and pale, 2–3 minutes. Beat in half of the powdered sugar. Add coconut milk, coconut extract, vanilla, and salt; mix until smooth. Beat in remaining sugar and whip 1 minute until fluffy, adjusting consistency with a spoonful more sugar or milk as needed.
Finish: Pipe or spread a generous swirl of buttercream on each cupcake. Press the tops into the toasted coconut to coat and, if desired, sprinkle with dark chocolate shavings.