My experience is that they certainly do understand when a companion has died, especially if they were present at the time. My original pair of girls were Linney and Frenzy. Around 18 months of age Frenzy developed severe dental issues. She was two and from the vet's repeatedly over the last few weeks of her life- both for brief checks and for two surgical appts where she was gone for hours. Each and every time Linney was frantic looking for her, and was excited to have her back and would nuzzle her and groom her and generally welcome her back. Unfortunately she was just too sick and eventually she passed away from massive infection. When she died, she was in the pigloo with Linney. When I found her, Linney had moved the pigloo off her body and to the opposite corner and Linney was obviously really agitated. When I took the body out to bury her, Linney didn't look for Frenzy or seem to expect her return. It's like she knew that she had died and wasn't coming back. And although she kept eating and drinking, she was very quiet and subdued. We did get a younger girl to be her friend, and after a couple of weeks of piggie quarantine we let Linney see her new friend and she perked up almost instantly- it was obvious she had been lonely and was thrilled to see another piggie! She was popcorning at the bars of the cage and wheeking! They definitely know when a friend has passed and feel the absence... they're social animals, and they do grieve.
I'm really sorry for your loss... it's so hard to lose a pet. I would suggest, especially since your remaining piggie is so young, that you seek out another companion for her. They really are happier in pairs, and having another pig as a companion will probably help her move past grieving.