How to set tile from ScriptedTile script?

I wanted to make a floor tile that would surround itself with walls. Since ITilemap has no SetTile method, what would be the best way to achieve this?

I use this.
Create a Tile and a Tilemap with a grid then use Tilemap → SetTile :
xpos, ypos, zpos are Grid positions

public Tile tile;

Tilemap tilemap = GetComponent<Tilemap>();
tilemap.SetTile(new Vector3Int(xpos, ypos, zpos), tile);

This only workes for me setting 1 tile at a time if I want to use multiple tiles I get some Tilemap Renderer sort issues