`wf-recorder` can do that. You can capture the whole screen with
wf-recorder -f out.mkv
Or just a section of it with (requires `slurp` be installed to)
wf-recorder -g "$(slurp)"
Use the `--audio` flag to capture audio.