For SharePoint Online, we can't change the site collection URL, we can change the sub site URL using PowerShell with CSOM. The following PowerShell script for your reference:
#Configure Site URL and User
$SiteURL = "https://mydomain/sites/sitecollectionName/subsite"
$User = "[email protected]"
$Password = "Password"
$newUrl= "/sites/sitecollectionName/mysubsite"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$SecurePassword)
$context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$context.Credentials = $creds
$web = $context.Web
$context.Load($web)
$context.ExecuteQuery()
$web.ServerRelativeUrl = $newUrl
$web.update()
$context.ExecuteQuery()
How to change the Subsite URL property using PowerShell in SharePoint Online