Prevent icon from appearing in my Mac's Dock when I text on my iPhone
When an icon appears in the Dock with a badge that looks like a stylized iPhone:

it means that macOS is making you aware that you started something on another device (a Mac, iPhone, iPad, or Apple Watch) and you could pick it up on your Mac. This functionality is called Handoff, which is one of a set of integration features called Continuity (other Continuity features include Universal Clipboard and Sidecar).
To turn Handoff off:

Launch System Preferences and click General

At the bottom of the pane, deselect “Allow Handoff between this Mac and your iCloud devices”: