Are you suggesting Dahl or Jsonnet ?
All that is needed are functions that can either directly contact the remote or build data model with which the tool will later do its magic.
See e.g. how you define infrastructure with Pulumi. It's just an example. I'm not advocating it. In fact, I have zero experience with it. But the point is, that it looks like imperative programming, but you're actually just building some model. You can employ language that's more functional. It doesn't matter.
Everytime someones mentions idempotence as a selling point of YAML abominations, they're mistaken. :-)