The writers of Spider-Man: Into the Spider-Verse share with Vulture the steps that went into using “Sunflower” in the movie:
It was critical that the song gag landed. We had a feeling it was because people knew the song, and they knew how he was messing it up. We were in big trouble when we couldn’t use it anymore — we needed to replace one of the greatest songs of the year, and we had to do it in time to spend the three months we would need to animate that shot. It turns out “Sunflower” is a massive hit song. We heard it as part of a batch of songs that Republic Records presented to us.
We also liked the metaphor this presents: Miles is singing a song that theoretically he’s a little too young for and he doesn’t know the words yet. That’s the metaphor we’re going to be working with for most of the rest of the movie. He’s going to be asked to step into shoes that he feels he’s not ready for, he’s not going to know the words, and he’s going to feel very self-conscious and nervous about that.
I love reading about the process behind decisions like this.