kubernetes configmap set from-file in yaml configuration

That won't work, because kubernetes isn't aware of the local file's path. You can simulate it by doing something like this:

kubectl create configmap --dry-run=client somename --from-file=./conf/nginx.conf --output yaml

The --dry-run flag will simply show your changes on stdout, and not make the changes on the server. This will output a valid configmap, so if you pipe it to a file, you can use that:

kubectl create configmap --dry-run=client somename --from-file=./conf/nginx.conf --output yaml | tee somename.yaml

You could use kustomize, and it manages not only configmaps but other resources easily. I think you wanted to create configmap from a file in yaml, so you could do something like the following in a kustomization.yaml file:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- files:
  - ./conf/nginx.conf
  name: nginx-config

Additionally, kustomize is very handy to manage all the deployments (particularly very handy for declarative management), and you can have everything in a single kustomize file as shown below:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
secretGenerator:
- envs:
  - .env
  name: my-secrets
configMapGenerator:
- files:
  - ./conf/nginx.conf
  name: nginx-config
resources:
- ./nginx-deployment.yaml

The to deploy everything you could run it like this:

$ kustomize build | kubectl apply -f -

For more information please refer here