It’s just wrong usage of fragment.
There are some ways to do that using serialization, but it’s super hacky and for such simple case just wrong direction.
Use DI or any other technique that allows fragment to request dependencies or maybe find some more simple solution and pass some data instead of lambda.
Hard to recommend something without real example