Depends upon your hardware and OS version.
Here in my 9‑current with ATA via CAM I can use e.g. “camcontrol identify 0:0:0” to see the status (“write cache”). I do not know of a way to change the write cache setting from the command line, but I think the loader tunable “hw.ata.wc” is honored by ATA via CAM too (set it to 0 to disable the write cache for all disks managed by the ATA part).
For my USB memory stick I can get a list of “modepages” via “camcontrol modepage 4:0:0 ‑l”. It shows 0×08 as the “Caching Page”, so “camcontrol modepage 4:0:0 ‑m 0×08” gives me the status for it (WCE means “Write Cache Enable”). To change this modepage add “-e” to the previous command line (I doubt any consumer-grade USB memory stick has a write cache, but you can use this for USB attached disks).
For ATA hardware not controlled via CAM, have a look at the atacontrol(8) man-page how to determine the current status of your disks.