Can you create a function in Python that can be referenced in the expression context?
No. Unlike the gdb expression parser, lldb’s expression parser is the clang front end. That keeps the parsing as accurate as we can make it, but means we don’t play tricks like pre-parsing to detect python functions and substitute their results or whatever.
Of course, if you have a C-python way to call the python function, you could certainly do that in the expression parser.