"ugly in a photo" could mean a lot of things. If you look bad in a selfie, that could be due to using a wide-angle setting on the camera (the default for most cell phones), which distorts any object that's close to the camera. It could be the lighting, too. If you look bad in all photos, even ones taken by other people from 20 feet away in good light, it could be that you are not photogenic.
In either case, you can understand and change your approach to having your photo taken if you learn to think like a model. All people have good points and bad points. When you look in a mirror, you are only seeing one point of view. The camera sees you differently.
To be "photogenic", you present yourself in a way that maximizes the good and minimizes the bad, at the moment the image is captured. Some people do this unconsciously, but you can learn.
As another example, I once knew a young woman who, to be honest, was rather plain. Both her face and body were roundish, she generally looked kind of gawky, but in every photo she always looked vivacious and pretty. Her smile, her eyes, the way she held her body just made her come alive. I don't know whether she did anything consciously or not.
For me, the big problems are my a big nose and weak chin, and I'm very tall and large-framed. When other people take pictures of me, the camera is low so they see a lot of my chin and the size of my nose is accentuated -- the worst view of me. I noticed by accident that a very few pictures made me look much better, and in those, I had my whole head pointed down, as if I had been looking at the photographer's knees but moved just my eyes to look into the camera lens. I look better when I am slightly behind other people (even if we're all in a row), because that makes me seem less huge. I started making those adjustments whenever anyone takes a picture of me, and I look a LOT better in photos. In reality, I am sure I look huge to everyone, but I don't care.
I don't know if you are handsome or not. But I do know you can do a lot to make yourself look better in photos with practice and by using a critical eye to discover your good points and make sure that's what's captured in the image.