The documentation says that it’s possible to get in to offboard mode via mavlink message, but I can’t figure out what that message is.
You can use MAV_CMD_DO_SET_MODE with:
param1: VEHICLE_MODE_FLAG_CUSTOM_MODE_ENABLED (1, see commander/commander.cpp)
param 2: PX4_CUSTOM_MAIN_MODE_OFFBOARD (6, see commander/px4_custom_mode.h)
You can refer the answer.