You can disable a lot of Godot's features when building the engine from source [1]. Not sure how much you can save while keeping most of the 2d/3d components, but it should be possible.
[1]: https://docs.godotengine.org/en/stable/contributing/developm...