If you're just trying to remove /blobname from the URL, you can simply use:
url = 'https://foo.blob.bar.storage.azure.net/container/blobname?sv=2015-04-05&ss=123&srt=abc&sp=efg&se=2022&sig=wsx'
new_url = url.replace('/blobname', '')
However, if you really want to parse the URL and reconstruct it (let's say you want to go up one directory in the URL path), you can do this:
from urllib.parse import urlparse, urlunparse
from pathlib import Path
url = 'https://foo.blob.bar.storage.azure.net/container/blobname?sv=2015-04-05&ss=123&srt=abc&sp=efg&se=2022&sig=wsx'
u = urlparse(url)
url_parts = list(u) # Need to convert to list to update the path item
url_parts[2] = str(Path(u.path).parent) # Using Path lib to go to the parent path
new_url = urlunparse(url_parts) # create a new URL
string.replace()won't do?/blobnamewould be the part to remove. I've posted an answer with details