When I add a layer from a GeoPackage (which was created using arcpy), ArcGIS Pro gives the layer a prefix of 'main.' which doesn't look great but can also mess with my arcpy tools due to the invalid '.' character.
Is there a way of avoiding this prefix being added to the layer name?
I don't think so, this is a SQLite feature (Geopackages are based on SQLite).
SQLite supports the ability to "attach" other databases to a single database connection. The first database opened before you attach other databases, is called "main" (there is also "temp" for temporary stuff) by default:
The database names ("main" or another "<YOUR_ATTACHED_DATABASE_NAME>") are essentially treated as database "schema" names by SQLite.
ArcGIS seems to inherit this structure (and I think for good reasons).
Since SQLite databases are here to stay in ArcGIS, especially now ESRI also introduced the SQLite based "Mobile Geodatabase" data format, I suggest you start adjusting your arcpy scripts to handle this, rather than trying to avoid this.
This will likely be the only viable option in the long run.