If there is a formula currently used to generate an ETOPS time, no regulatory agency has made it public that I can tell. ETOPS originally grew out of a "60-minute rule" that was the result of earlier distance-based rules (see this report for a thorough history). My guess is that 60 minutes was a case of "well, that sounds good" rather than the result of any rigorous analysis. From there, it's mostly been manufacturers slowly pushing and getting approved for longer and longer extensions (usually just a percentage increase that results in round-ish numbers—again, this is policymaking, not engineering).
However, take a look at the formulas on pages 9–11 of this report. I hesitate to declare them the way to generate an ETOPS number because the report is thirty years old and a lot of it is critical of the methodology, so the regulators may have changed their approach between then and now. In fact, the report does not explicitly state that the formulas within were in use at the time, either. Nevertheless, if there is a formula in modern use, it likely uses a similar approach of quantifying the probabilities of failure and using a factor to convert them into a do-not-exceed diversion time.
The difference between certification at 330 minutes (777) and 370 minutes (A350) may be due to FAA vs. EASA methodologies and/or decreases in inherent failure probabilities as technology matures. With that, I doubt there is much difference in maintenance of a 777 vs. an A350 (at least as far as ETOPS goes—obviously their construction necessitates very different maintenance programs), as that 40-minute increase for the A350 was approved without any in-service maintenance data. It may be different for the 787, which was not initially certified at 330 minutes.
Going forward, I have no doubt we'll see ETOPS 430 and above. Airbus already toyed with 420 minutes for the A350, and perhaps we'll see that after some time in service. At 420 minutes, there are only a few non-compliant routes; I expect that, eventually, any new twin will be able to fly unrestricted between any two points within its endurance.