With iOS 26 it takes four taps and no computer. Here's how, plus the older GarageBand and Mac methods.
On iOS 18 or earlier: import the file into GarageBand on your iPhone (Loops → Files → Browse items from the Files app), drag it onto a track, then in My Songs press and hold the project → Share → Ringtone → Export. On a Mac: connect your iPhone, select it in the Finder sidebar, and drag the .m4r file onto its window.
Yes, on iOS 26: open the audio file in the Files app, tap Share, then Use as Ringtone. The file must be 30 seconds or shorter.
On iOS 26, an M4A, M4R or MP3 file of 30 seconds or less works from the Share sheet. M4R is the classic ringtone format used when syncing from a Mac.
Make sure you're on iOS 26, the file is audio and under 30 seconds, then tap More in the Share sheet. Quitting and reopening Files can help.
Once it's added, it appears in Settings → Sounds & Haptics for ringtone, text tone and other alerts, and in the Clock app's alarm sound list.