Combine 2 1/2 cups water and lentils in a saucepan; bring to a boil. Reduce heat, cover saucepan, and simmer until all the liquid is absorbed and lentils are tender, 20 to 30 minutes.
Mix 1/3 cup water and ground flax seed together in a bowl; set aside until thickened, at least 10 minutes.
Heat olive oil in a large pot over medium heat; cook and stir onion, mushrooms, celery, and garlic until softened and liquid from mushrooms has evaporated, 5 to 10 minutes.
Preheat oven to 350 degrees F (175 degrees C). Grease a loaf pan.
Transfer cooked lentils to a food processor and pulse until about 75 percent of lentils are mashed. Mix onion-mushroom mixture, flax seed-water mixture, oats, flour, basil, black pepper, salt, and onion powder into lentils until well combined. Press lentil mixture into the prepared loaf pan.
Combine ketchup, brown sugar, mustard, and barbeque sauce in a saucepan over medium-low heat; cook and stir until glaze is smooth and brown sugar is dissolved, about 5 minutes. Remove saucepan from heat.
Bake loaf in the preheated oven for 35 minutes. Spread 1/4 cup glaze over lentil loaf; continue baking until cooked through, 10 to 15 minutes more. Serve lentil loaf with remaining glaze on the side.