@vinoman It is in fact very simple. See here an example with pictures:
Say I want to remove GNOME MPV from my task bar:
First, I right-click on its icon, which will show me this menu:
Note that the star on the left is currently filled, which means it is favorited/pinned.
So I click on that icon to unfavorite. DONE.
If GNOME MPV is currently running, the icon will still stay in the task list until you close it. A right-click in that case will show you the following:
Note that the star is not filled, which means it is not favorited/pinned.
As soon as you close the app however, the icon will disappear. (same as for all unpinned apps).
In case you're talking about an other icon (that is, not one from the app bar) it would be best if you'd just tell us exactly what you want to remove, as others have suggested. Otherwise it's hard to help you.