I think it depends a lot on the relationship the patient (and the patient's family) has with the doctor. If there is no close relationship (like, if it was a recent location to a new CF center), then it may feel inappropriate to the patient's family.
I know that in my experience, though, having my fiance's doctor there was invaluable. He was the only person around for me when Allan went into respiratory failure and was put on a ventilator a week before he actually died. Neither of us had any friends or family around that day. I don't remember if his doctor was actually in the room at the exact moment, as I was really focused on Allan and I don't like to try to remember all the details anyway, but he was there beforehand to explain exactly what was going on, what would happen, the likely time-frame and to get permission to not try to resuscitate (I had to try to translate this to his Russian-speaking father).
But you're asking if they should morally be around. There are going to be some very sad cases where no one else is around, and I think that the doctor should definitely be with their patient in that case (or a close nurse, perhaps), especially if the patient has ever implied that they don't want to be alone at the end. If there's family around, then I think they should keep a bit more distant but try to still be close by to be supportive of the family before and afterward. It did help, even in some small measure, to see his doctor and other hospital staff with tears in their eyes too, and know that his death affected him as well.
I just know that, without his doctors' support I would have been far worse off, emotionally.
As far as funerals go--I don't see why not. Again, I would have to think that what feels right to the family would be the best gauge of what is appropriate. Unless it was some serious medical mistake on the doctor's part that contributed to the death of the patient, I don't see much of a dilemma there. I don't think a doctor should be expected to attend, however...it may not be possible, or the doctor may feel its inappropriate. Allan was closer to his CF doctor in NY than he was to most other people, and seeing her there would have only been a comfort to me (but then, the only people at his funeral were his mother, father, stepfather, my father and me--and the oldest Russian Orthodox priest and nuns ever. I know how well-loved he was and how many friends he had, but it was so depressing that his funeral didn't even show a glimpse of that...)