macbook – yes loop takes the CPU usage to 99%

This is because the Activity Monitor displays CPU usage as a percentage of a single heart. So, 100% means that a kernel is fully occupied.

The percentage can therefore be greater than 100% when a program uses multiple cores.

The "yes" program is designed to use only one kernel and use it fully. Therefore, the behavior you observe is completely normal.