Cook the lentils. In a medium saucepan, combine lentils and vegetable broth. Bring to a boil, then reduce heat to a simmer. Cover and cook for about 25-30 minutes until lentils are tender but not mushy. Drain any excess liquid and set aside to cool.
Preheat your oven to 375°F (190°C). Line a 9x5 inch loaf pan with parchment paper, leaving some overhang for easier removal.
Prepare the flax "egg." In a small bowl, mix ground flaxseed with 6 tablespoons water. Let sit for at least 5 minutes to thicken.
Sauté the vegetables. Heat olive oil in a large skillet over medium heat. Add onion, carrots, and celery with a pinch of salt. Sauté for about 5-7 minutes until softened. Add garlic and cook for another 30 seconds until fragrant.
Add the mushrooms. Increase heat to medium-high and add chopped mushrooms. Cook for 5-8 minutes, stirring occasionally, until mushrooms have released their moisture and are beginning to brown.
Build flavor. Stir in tomato paste, tamari, thyme, sage, smoked paprika, and rosemary. Cook for 2 minutes, stirring constantly. Remove from heat and let cool slightly.
Process the lentils. Place cooked lentils in a large bowl and mash about half of them with a fork or potato masher, leaving some whole for texture.
Combine everything. Add the vegetable mixture to the lentils along with the flax mixture, oats, walnuts, nutritional yeast (if using), salt, and pepper. Mix thoroughly until everything is well combined. The mixture should hold together when pressed.
Form the loaf. Transfer the mixture to the prepared loaf pan, pressing it down firmly and smoothing the top with a spatula.
Make the glaze. In a small bowl, whisk together all glaze ingredients until smooth. Spread evenly over the top of the loaf.
Bake covered. Cover the loaf with aluminum foil and bake for 30 minutes.
Bake uncovered. Remove the foil and bake for an additional 20-30 minutes until the top is set and the glaze is caramelized.
Rest and serve. Let the loaf cool in the pan for at least 15-20 minutes before removing and slicing. This resting period is crucial for the loaf to firm up and hold its shape when sliced.