This seems to be the issue (segmentation fault):
/bin/sh: line 1: 91925 Segmentation fault: 11 erlc -W -Werror +debug_info -DENABLE_MEGACO_FLEX_SCANNER=true -DMEGACO_REENTRANT_FLEX_SCANNER=true -Dmegaco_parser_inline -pa /Users/aaggarwal/.asdf/plugins/erlang/kerl-home/builds/asdf_25.2/otp_src_25.2/lib/et/ebin -pa /Users/aaggarwal/.asdf/plugins/erlang/kerl-home/builds/asdf_25.2/otp_src_25.2/lib/megaco/ebin +'{parse_transform,sys_pre_attributes}' +'{attribute,insert,app_vsn,"megaco-4.4.2"}' -I../../include -o../../ebin megaco_flex_scanner.erl
It looks like you’re compiling in Rosetta (x86_64) mode instead of in ARM mode. Is this on purpose? I’d retry with ARM, I’ve noted people have had segfaults when using the wrong architecture on M1, though I don’t have M1 myself so I don’t have experience.
EDIT: Further looking at your OpenSSL location, it seems your Homebrew is installed in x86_64 mode (install location is /usr/local
for macOS Intel, /opt/homebrew
for Apple Silicon). I’d recommend reinstalling homebrew and the rest of the tooling, making sure you are in Apple Silicon mode in the terminal.