The most reliable way to change icon size without potentially "breaking" the taskbar is to adjust your system-wide scaling. This affects the taskbar icons, text, and all application windows. Change Taskbar Icon Size - Microsoft Q&A
For advanced users, it is also possible to change the taskbar icon size using the Registry Editor. To do so:
If the registry method or third-party software causes the taskbar to disappear:
If you just want the taskbar to take up less space without editing the registry: