Add effective error handling to Python Notebook in Azure Synapse Analytics
Ignoring your closed-connection and managed-identity questions, since (a) I don't know how to answer them and (b) on their own they're off topic, there is still review to be done:

A Pythonic way to tell the standard library to format your URI instead of you doing it yourself is to call into urlunparse
Consider using pathlib
connect accepts kwargs as an alternative to the conn string, and the former will lay out your connection parameters more nicely
except / raise is redundant and should be deleted
Your try starts too early and should only start after the connection has been established
You're not reading a lines list; you're reading content, which would be a better variable name

Suggested
from pathlib import Path
from urllib.parse import urlunparse, ParseResult
import pyodbc
from pyspark import SparkFiles


pAccountName = 'someStorageAccount'
pContainerName = 'someContainer'
pRelativePath = '/raw/sql/some_sql_files/'
pFileName = 'someSQLscript.sql'

# Add the file to the cluster so we can view it
sql_filename = urlunparse(
    ParseResult(
        scheme='abfss',
        netloc=f'{pContainerName}@{pAccountName}.dfs.core.windows.net',
        path=f'{pRelativePath}{pFileName}',
        params=None, query=None, fragment=None,
    )
)

sc.addFile(sql_filename, False)

# Open the file for reading
sql_file_path = Path(SparkFiles.getRootDirectory()) / pFileName
with sql_file_path.open() as f:
    content = f.read()

# Open the database connection
conn = pyodbc.connect(
    DRIVER='{ODBC Driver 17 for SQL Server}',
    SERVER='someServer.sql.azuresynapse.net',
    DATABASE='someDatabase',
    UID='batchOnlyUser',
    PWD='youWish',
    autocommit=True,
)

try:
    # Split the script into batches separated by &quot;GO&quot;
    for batch in content.split(&quot;GO&quot;):
        conn.execute(batch)  # execute the SQL statement
finally:
    conn.close()