Like all great questions in science, the answers are found best when we agree upon the definition of our topic. First, lets define consciousness as it is often confused with self-awareness. There as many definitions of consciousness as their are theories about what makes something "conscious." For our purposes here, I will define consciousness as "an aroused state" (Pastorino & Doyle-Portillo, 2018). To simplify, consciousness is our light switch turned "on." Awareness and self-awareness are properties of consciousness (Gallup, 1977). If consciousness is our light switch turned "on" (an aroused state), self-awareness would be our ability to realize we are "on." Furthermore, it is our ability to self-recognize that we are us and separate from other objects or beings.
To determine which animals are or are not self-aware, we need to further define the criteria for what we will agree does or does not constitute self-awareness. Then, we must conduct a test to see which animals meet the criteria. The most iconic example of this is known as the "rouge test" or the "mirror test." Originally developed by Gallup in 1970, this test involves placing a spot of red dye on the face of an animal and presenting the animal with a mirror. If the animal sees the red dye mark in the mirror and touches it, that animal is considered to demonstrate visual self-recognition - or - self-awareness. In the 1970 study, Gallup noted that chimpanzees began to use the mirrors to look at areas of their own bodies that they normally cannot see.
As others mentioned, this is not the only way of defining or identifying self-awareness. Cognitive Ethicist, Dr. Marc Bekoff, has long proposed applying an evolutionary perspective to self-awareness. He suggested an alternative to making the extent to which primates can demonstrate self-awareness (e.g. rouge test) as the gold standard to which all animals are held (Bekoff, 2003). This means considering how each animal demonstrates its own ability to self-recognize according to how it has evolved to survive and what needs it has relative to survival. For example, dogs can use scent to recognize their own urine. An animal can defend itself when it recognizes its body is being attacked. Some birds can identify their own songs. My pet tarantulas use scent to sense their general territory and to understand when another tarantula wants to mate. According to Bekoff, who takes an empathetic approach to animals, our traditional definitions of self-awareness have been unfair to some animals and cause us to overlook their amazing innate abilities.
To recap, self-awareness is the ability to recognize one's own self in some capacity relative to its need to survive and thrive in its environment. As to what animals can do this - that all depends upon the criteria you set for testing and defining self-awareness.
Bekoff, M. (2003). Consciousness and self in animals: some reflections. Zygon: Journal of Religion & Science, 38(2), 229–245. https://doi.org/10.1111/1467-9744.00497
Gallup, G. (1970). Chimpanzees: self-recognition. Science. 167. 86-87. 10.1126/science.167.3914.86.
Gallup, G. (1977). Self-recognition in primates: a comparative approach to the bidirectional properties of consciousness. American Psychology. May 1977. 330-338. Retrieved at: https://pdfs.semanticscholar.org/32d2/dd1fb12aaf89a1bfdfb115479ac0fe07ecc2.pdf
Pastorino, E. & Portillo, S. (2019). What is psychology? : foundations, applications, and integration. Australia: Cengage.