Yes, both of your attempts are right. Anyway "asentir con la cabeza" sounds a bit to literary or typical of written language. I spoken language people might just say "decir que sí con la cabeza". "I asked her if she would go with us and she nodded her head"="Le pregunté si vendría con nosotros y dijo que sí con la cabeza". To shake your head ( to say no) would be "negar con la cabeza" in literary or written language and "decir que no con la cabeza" in spoken language.