While it definitely is your best bet to work with your medical team, there are a few different avenues that you can specifically ask about with them:
1 - myofascial release
Part of your current issue could be an increase in tightness of the fascia. The best treatment that I'm aware of is from a certified Massage Therapist who can do the release, and who can teach you how to maintain a certain level of release at home using a foam roller (make sure you get them to teach you how to do it safely).
2 - piriformis syndrome or sciatica from other causes (such as herniated disc)
Sciatic nerve twinges can be caused by tightness of the piriformis muscle, or by other herniated discs, and can cause cramping. A quick (and safe) test that you can do to get an idea of whether one of these is contributing to your current issues can be found here: www.youtube.com/watch?v=e3r29g7k2Hk
You can share the results of this test with your doctor as a starting point to decide whether this is contributing to / causing the current issues, and what best treatment is. If piriformis is suspected, then the certified Massage Therapist can help again, and can teach you safe foam roller releases for this, too.
3 - electrolyte imbalance
Since taking magnesium seems to help you, I'm thinking that you might be suffering from an overall depletion of electrolytes. We all lose more electrolytes when we sweat, so hot weather and working harder than usual can definitely cause a temporary imbalance --- especially when we are carefully following low sodium intake recommendations and increasing our plain water intake, with no attempt to increase our electrolyte intake.
You can check your most recent blood work to see if your doctors tested for electrolyte levels, and it definitely should be part of your conversation with them next time. In the meantime, try increasing your intake (by food or supplement) of potassium, sodium chloride (salt), and calcium along with the extra magnesium. There are numerous electrolyte drink or powder options on the market (such as Pedialyte), or you can make your own, or you can just include a couple of shots of pickle juice or enjoy a heavily salted fruit salad with melons and bananas with a side of yoghurt.
While this is a biased opinion piece, it will give you a place to start the conversation with your doctors (and happens to be in full agreement with the opinion and recommendations of my Cardiologist): https://hackernoon.com/the-science-of-salt-and-electrolytes-are-we-consuming-enough-7299e8f398f1
Good luck, and hopefully you will find the cause and feel better soon!
Sir Terry Pratchett:
"Science is not about building a body of known 'facts'. It is a method for asking awkward questions and subjecting them to a reality-check, thus avoiding the human tendency to believe whatever makes us feel good."