Hi @Peter,
The Script Editor is not the build-in option in the Modern SharePoint site currently. As this article mentioned, for security reasons, modern web parts do not allow for the insertion of code like JS and css. If you are familar with codes, Script editor web part for modern pages built in React and Add The Script Editor Webpart back to SharePoint Modern Experience might be helpful for your requirement. You can learn more about spfx by following document
https://learn.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.