If you are close enough you can see the attack animation on the gym. If you are in game you'll get s remote notification your 'mon wants a berry.
Once I was needing to make bag space, decided to feed gyms and got really lucky.
My favorite was when a lady was trying to take down a gym. I sat around the corner where she couldn't see me and keep giving golden berries. she was getting pissed that the Pokémon wouldn't go down. I finally walked over to her and asked if she was battling the gym, and told her I was having a glitch and the Pokémon would lose motivation. She reported the "glitch" to Niantic 🤣🤣🤣