I saw that many 3D classes and methods have been exposed to PyQGIS so I was wondering if choosing a raster layer as a terrain was now possible. I'm working on QGIS version 3.36.1.
This is the GUI interface (in french) from which we can perform this manually :