There’s some examples in this config of how to set up a template binary sensor which only gets updated from “manual calls” elsewhere in the code.
Search it for batt_level_recieved for example.
I don’t think binary_sensor.template.publish can be called from HA, only inside ESPHome.