Yes, there are various ways to calculate MAGI. To calculate MAGI for Roth contribution eligibility, fill out Worksheet 2-1 in Pub 590-A at
https://www.irs.gov/publications/p590a#en_US_2022_publink1000230985.
You have multiple options to avoid the 6% excise tax on excess contributions:
1. You can wait until the spring time to figure your MAGI and then make an appropriately sized Roth contribution. Around now, you should be able to figure your AGI for 2023, and you have until April 15, 2024 to make a 2023 Roth contribution.
2. You can do a backdoor Roth, which involves making a nondeductible contribution to a traditional IRA then converting the contribution to a Roth. This is a well known workaround and avoids any MAGI-imposed limits, although there is at least one caveat that you should read up on before heading down this path.
3. You can contribute to your Roth, and then if you end up being over the contribution limit for your MAGI, you can either (a) withdraw the contributions plus earnings by the due date of your return (plus extensions IIRC), or (b) recharacterize the contribution or a portion of it to a traditional IRA (after which you can, somewhat confusingly, do the backdoor Roth option above). Nobody will warn you, but if you're aware of the issue and paying attention, you can fix it without too much trouble.
HTH.