Is the Sun homogeneous? Does the Sun have the same composition and density everywhere within it? How does it vary in other stars?
No, the sun and all other stars do not have the same composition and density within them.

The composition varies with depth. Most stars overall composition reflects the interstellar medium from which they form. Convection, settling and nuclear processes then lead to layers of different elements at differing depths.

Fusion occurs at the core of our sun (where pressure and temperature are greatest) therefore there is a greater abundance of Helium at this depth (through conversion of hydrogen). Other stars that have entered the red giant phase will also have many more heavier elements. Very late stage stars are thought to fuse these elements progressively, leading to layers of decreasing atomic number elements stacked on top of each other.

Convection can also lead to mixing of elements between layers. The diagram below shows theoretically how these convective layers differ over a range of stellar masses



The density increases as you move closer to the center of the star. Note how the density is less than that of water for up to half the sun's radius!