Depends on your phone, on your carrier, and on which SMS app you are using.
Your phone needs to support wifi calling and have it turned on.
Your carrier and chosen plan needs to support wifi calling and wifi texting.
You may need to use the SMS app from your carrier. Some third-party SMS apps will support SMS over wifi but not MMS over wifi.