Preheat the oven to 350°F (175°C). Grease an 8-inch or 9-inch round cake pan and line the bottom with parchment paper. This helps the cake release easily after baking.
Place the shelled pistachios in a food processor and pulse until finely ground. Avoid processing them for too long, as the nuts may release oil and turn into a paste. Set aside.
In a medium bowl, whisk together the flour, ground pistachios, baking powder, and salt. Mixing these ingredients evenly helps the cake rise consistently and distributes the pistachio flavor throughout the batter.
In a large mixing bowl, beat the softened butter and granulated sugar for approximately 3–4 minutes until the mixture looks light and fluffy. This step incorporates air into the batter and contributes to a tender cake texture.
Add the eggs one at a time, beating well after each addition. Mix in the vanilla extract and optional almond extract. Scrape down the sides of the bowl to ensure the ingredients are evenly incorporated.
Add the dry ingredient mixture in two or three portions, alternating with the milk and yogurt. Begin and finish with the dry ingredients. Mix on low speed just until combined. Add a small amount of green food coloring if you prefer a brighter green cake.
Pour the batter into the prepared cake pan and smooth the surface with a spatula. Gently tap the pan on the counter to release any large air bubbles.
Bake for 30–40 minutes, depending on the pan size and your oven. Insert a toothpick into the center; the cake is ready when it comes out clean or with a few moist crumbs. If the top browns too quickly, loosely cover it with foil.
Let the cake rest in the pan for 10–15 minutes before transferring it to a wire rack. Allow it to cool completely before frosting. Applying frosting to a warm cake may cause it to melt.
Beat the softened cream cheese and butter until smooth and creamy. Gradually add the powdered sugar, followed by the vanilla extract. If the frosting is too thick, add milk or cream a teaspoon at a time until it reaches a spreadable consistency.
Spread the cream cheese frosting evenly over the cooled cake. For a layered cake, divide the batter between two prepared pans, bake until done, cool completely, and spread frosting between the layers and over the top.
Sprinkle chopped pistachios over the frosting and arrange a few whole pistachios on top. Add fresh berries if desired. Slice with a clean knife and serve at room temperature for the best texture and flavor.