what can I use to cushion my knee when exercising with it on the floor so it doesn't hurt?
yes, a cushion, but every one I've found is too big and doesn't fir my backpack where I have more stuff (clothes, an umbrella...).
I like doing yoga and stretching outdoors, so the ground may also have loose dirt, broken pebbles and grass...
If I bend on my fours, raise-stretch a leg with the other leg's knee touching the ground to hold most of my weight with this leg's foot stretched to the back and still touching the ground, raise-stretching one arm and only using the other arm not to fall to the ground, the knee touching the ground hurts.
I've tried folding a small towel three times, but I'm so skinny that my knee still hurts.
I use a large folded microfiber towel as knee support in pilates. It’s not as spongy as a normal towel but soft and supportive enough for those exercises that put a lot of stress on my knees or tailbone.
Depends on the type of yoga mat! Some are very thick, some are very thin. Sounds like you got one of the thinner ones. You couldn't possibly fold one the thick ones, it would open up on its own without a weight on it whereas the thin ones can stay as you leave them.
A kneepad is another option as many said already.
You also have mats for camping, my parents had a couple of these and they would lay them under the sleeping bags precisely to avoid feeling all the debris on the ground.
Look for a knee pad for gardening. Go to the gardening section of your local home improvement store. They're just big enough to kneel on. If that's still too big, maybe look for an inflatable camp pillow or camping cushion of some sort.
Hunting/sports sections will have foam pads like these for sitting on while hunting/fishing or in bleachers etc. Have had one in my gym bag for years for knee-ground-exercise things.
Hover your knee off the ground when you are in the all-fours helps. Like don't put your whole weight on it. Do poses that don't put as much weight on your knees.
Look for better ground to practice, grassy areas.
When I yoga outside, it's the last suggestion I use the most. My knees are also sensitive, and finding a flat surface, then using my usual sorta thick yoga mat works well.
In my homegym I have an AbMat foam pad which I also use as a knee pad. And while I think the thick foam would work outdoors on tougher terrain, it would not meet your criteria to fit in a backpack.
My other suggestion would be a scrap piece of horse stall mat, which are nearly solid rubber sheets commonly employed for homegym floors. This is what I use when working in my yard, for tasks requiring a lot of kneeling. Such a piece -- while heavy -- could be cut to whatever size you need, using a sharp knife or a jigsaw.