Process raw pistachios in a food processor in 10-second bursts until finely ground to a dry, sandy crumb. Stop before they become oily or clump. Set aside.
Preheat oven to 175°C (350°F). Grease two 9-inch round cake pans, line bottoms with parchment, and grease the parchment.
Whisk together ground pistachios, flour, baking powder, baking soda, and salt in a bowl until evenly combined.
Beat softened butter and sugar in a stand mixer on medium-high for 3 to 4 minutes until pale and fluffy, scraping the bowl once.
Add eggs one at a time, beating 30 seconds after each. Add vanilla and almond extract. Add sour cream and mix on low until just combined.
Add dry ingredients in three additions alternating with milk in two additions, folding gently after each until just combined. Do not overmix.
Divide batter evenly between the two prepared pans. Bake 28 to 32 minutes until pale golden, edges pull from pan sides, and a toothpick comes out with clean dry crumbs. Cool in pans 10 minutes, then invert onto a wire rack and cool completely before frosting.
Beat room-temperature cream cheese and butter together until smooth. Add sifted icing sugar in three additions, mixing on low. Add vanilla and salt. Add cream or milk 1 tablespoon at a time to reach a smooth, spreadable consistency.
Stack and frost the cooled layers. Press crushed pistachios into the frosted top and sides. Refrigerate 20 minutes before slicing. Serve at room temperature.