I'm fairly convinced diet plays a role in male pattern baldness, no doubt. male pattern baldness seems to have gone up across the world globally, in relation to increased industrialization and economic development in the world. On top of that, it seems to be happening at a younger age too. Most of these developing countries are shifting to the Western diet, which is full of unhealthy and disgusting processed sh*t. But it's all fairly cheap, really.
The Western diet is generally quite acidic, as it consists of a lot of grains (which are all acidic), meat (also acidic), dairy (acidic too, usually), sodas (they literally have mild acids added to them), and not a lot of vegetables or fruits, which are generally a lot more basic. The optimal pH of 5 alpha reductase (although there are really 3 types discovered so far) is about 5.5. That is decently acidic. For context, 0-7 is considered acidic, and 7-14 is considered basic. If you were to eat a pure vegan diet, your blood pH should increase with the increased uptake of vegetables (assuming you don't just fill in the calorie gap with a bunch of grains, which might actually happen if you go full vegan), which will make the enzyme less efficient at converting testosterone to dihydrotestosterone (DHT), and thus the reduced DHT should lower male pattern baldness. Of course, that's assuming that you're eating hardly any grains at all on the vegan diet as a substitute for meat and dairly calories. Grains, especially wheat, are even worse in terms of acidity than even red meats are. Legumes (basically beans), which also includes soybeans, are also quite acidic. Unfortunately, a lot of vegans end up subsituting legumes and various whole grains in place of meat. This is actually terrible for your body; grains, even whole, are full of antinutrients and are lacking in actual nutrients, and soy is notoriously terrible for men across many metrics. As far as I'm concerned, if you go full Vegan, you may slow down your hair loss slightly because you are eating less processed sh*t, but unless all you literally eat are vegetables and some fruits, you're still consuming a fair share of acidic foods and also likely a lot of antinutrients. That isn't going to improve your blood pH that much. Not to mention, there are a lot more nutrients in meat than you might initially think they are, and are a lot more bioavailable for your body to use than nutrients in vegetables, especially if you eat your vegetables raw. Cooking vegetables is actually good; yes, cooking will damage the nutrients, but it will also make the remaining ones a lot easier for your body ot use.
I think the ideal diet would probably be this: eliminate all grains and legumes from your diet, and either fully eliminate or strongly cut back on your dairy consumption. Eat plenty of vegetables and meat, though don't go completely overboard on either one. No processed sh*t allowed either.
Even then if you did that, I doubt it would be enough on its own to stop and/or reverse hair loss naturally.