You could consider usingcan find inspiration here on how to avoid polluting the global namespace: https://developer.mozilla.org/en-US/docs/Glossary/IIFE#avoid_polluting_the_global_namespace
Your shared JS would be an IIFEstill contain 1 global (the function) that you could call with a config object like
<script>
initializeMapLogic({
bgLayerName : '@Model.DefaultBackgroundLayer',
infoLayerName : '@Model.DefaultInformationLayer',
onlyEnablePolygon : true,
allowMultiplePolygons : true
});
</script>