This method may not work on the recent versions of Ubuntu 20.04 LTS. (Host OS and WSL-2 in Win.10). You can try at your own risk.
There are multiple ways to install NS-3 on Linux OS. You can Google it to find those. Personally I prefer to collect the necessary commands and then create a bash script to be used in future.