I found a way using the properties of the filepath rather than the dynamic label:
import arcpy
import os
# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")
# Access the full file path of the project
project_path = aprx.filePath
# Extract the project name from the file path
project_name = os.path.basename(project_path)
print("Project Name:", project_name)