If originalMaterial = skeletonAnimation.GetComponent<MeshRenderer>().material
returns null, you most likely called it too early, before it has been assigned for the first time.
You could also access the first atlas page material in this way:
Material material = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial; // or via .Materials