I play Animal Crossing with a digital copy in a second profile linked to my friend's account. I want to buy the DLC on my main account. This DLC will be shared to the second account in this situation? I don't own a copy of Animal Crossing on my Main Account.
I cannot say for certain if it works with Animal Crossing however, I was in a similar situation for Pokemon Sword and Shield (please see my answer here for a similar question but for Pokemon: Are the Pokémon Sword and Shield expansion version exclusive?)
Basically, I bought the Expansion for both Sword and Shield on one account. My switch has 3 profiles. Every profile could play the expansion on both games, even though it was only bought with the primary.
I would be very surprised if it works differently for Animal Crossing as I feel like this wouldn't be a per game restriction and would be a per device restriction.
However, as you said that you play it with the digital version on the second account, it may not actually work, as my experience has been with either everyone using the same phycial version or everyone using the same digital version, not a mixture of both. I sadly cannot test that for you as I am not going to rebuy either Sword or Shield.
Extra Speculation, not guaranteed to be true:
If it helps, I have had some experience with a modded switch and the ID of the game is not different depending on if it is a digital version or a physical version, so that may mean the DLC will work with both. But please do note, this part is pure speculation.