Usually yes — an ordinary magnesium supplement is not known to dangerously interact with statins, but magnesium-containing antacids can lower how much statin you absorb, so separate them and check with your pharmacist.
Magnesium and statins work in unrelated ways, and authoritative drug-information sources do not name statins among magnesium's known interactions — those are bisphosphonates, tetracycline and quinolone antibiotics, plus diuretics and proton-pump inhibitors that affect magnesium levels (per the NIH Office of Dietary Supplements magnesium fact sheet). The one documented statin link is with magnesium-and-aluminum-hydroxide antacids (a different product from a plain magnesium tablet): the FDA Lipitor (atorvastatin) label shows that a Maalox-type antacid lowered atorvastatin blood levels by about a third (AUC fell to ~0.66 and Cmax to ~0.67). Atorvastatin labels have historically noted that LDL-cholesterol lowering was not actually reduced despite this drop in drug levels, but the linked label section reports only the pharmacokinetic numbers, not the lipid outcome. This is an absorption/binding effect, which is why spacing the doses is the standard way to prevent it.
Take a statin and any magnesium-containing antacid (or a magnesium product like magnesium hydroxide that doubles as an antacid) at least 2 hours apart so the statin still absorbs properly — antacid spacing is a standard precaution noted on statin labels. Stick to magnesium within sensible limits: the tolerable upper limit is 350 mg/day of magnesium from supplements for adults, and high doses cause diarrhea, nausea and cramping (people with kidney disease should be especially careful and ask a doctor first). Statin warning signs to report regardless of magnesium are unexplained muscle pain, tenderness or weakness, dark urine, or yellowing of the skin/eyes. Tell your doctor or pharmacist about every supplement you take, since supplements are not tested for interactions the way prescription medicines are, and check with a professional before combining if you have kidney problems, take other medicines, or notice new muscle or digestive symptoms.
This is general reference, not medical advice, and not a guarantee of safety. Interactions depend on your doses, health conditions, and other medicines. Always confirm with your pharmacist or doctor before combining products, and follow the dosing on each label.