Preheat oven to 350°F (175°C) and line two baking sheets with parchment paper or silicone mats.
In a medium bowl, whisk together flour, baking powder, baking soda, and salt until evenly combined. Set aside.
In a large bowl, cream the softened butter and sugar with a mixer on medium speed for 3-4 minutes until pale and fluffy. Scrape down sides of bowl.
Add the egg yolk, vanilla extract, and almond extract if using. Mix on low until combined, then beat on medium for 1 minute until smooth and creamy. Scrape down sides.
Add the sourdough discard and mix on low until fully incorporated and the mixture is smooth and cohesive.
Add the dry ingredients in two additions, mixing on low after each until just combined. Do not overmix. The dough should be soft and slightly tacky.
For drop cookies, scoop 1.5 tablespoon portions, roll into balls, and optionally roll in extra granulated sugar. Place 2 inches apart on baking sheets.
For cut-out cookies, roll dough to ¼-inch thickness on a lightly floured surface, cut shapes, and transfer to baking sheets with a spatula.
Bake one sheet at a time for 10-12 minutes until edges are set and very lightly golden. Centers will look slightly underdone. Cool on pan for 5 minutes, then transfer to a wire rack to cool completely.
If frosting, whisk powdered sugar with heavy cream or milk until smooth and drizzleable. Add food coloring if desired. Drizzle or spread over cooled cookies.