Android 12 has yet to be announced but there are already features that have been revealed about it. We recently learned about the Hibernation mode and now it has been reported that it will allow you to share Wi-Fi passwords with nearby devices.
For you to use it though, it may require you and your friend to run on Android 12. What protocol the sharing will take place is also unknown as of writing. We may just have to wait until the developer preview releases.