In llvm-project, obj2yaml pretty prints an object file in YAML and yaml2obj can convert the output back to an object file.
The test cases are a good way to explore the functionality: https://github.com/llvm/llvm-project/tree/main/llvm/test/too... https://github.com/llvm/llvm-project/tree/main/llvm/test/too...