Yes
Food: Comets already contain amino acids and elements necessary for life as we understand it. Other sources are interstellar dust.
Energy: Photosynthesis, as you suggested, would work well near stars. It may be beneficial to metabolize cosmic radiation too.