The best possible way (for the dog), to put a dog to sleep is to hire someone to come to the dog's home and do it there, where the dog is most comfortable and in the least amount of stress, and in the presence of their human who they love and trust. There are numerous vets who will perform this service or recommend someone to do it. If you can't (or won't), do that, absolutely you should be in the room with your dog even if you're crying. The dog will feel less anxious if their human is with them, speaking to them and stroking them. Your presence will make it better for your friend, not worse. And you have my condolences. I know what this is like.