You can use built-in variables:
https://github.com/docker/buildx/blob/master/docs/bake-reference.md#built-in-variables
The following variables are built-ins that you can use with Bake without having to define them.
Variable Description BAKE_CMD_CONTEXTHolds the main context when building using a remote Bake file. BAKE_LOCAL_PLATFORMReturns the current platform’s default platform specification (e.g. linux/amd64).
And there are variables in a Dockerfile
https://docs.docker.com/build/building/variables/#multi-platform-build-arguments
Then you can write conditions in scripts.
Is it what you were looking for?