It is possible - most simulators (should) support the basic SPICE model syntax. That said, accuracy of models depends on the correctness and amount of parameters that are entered into the model file or code (especially for semiconductors). So yes, you can write your own SPICE models but they might not be accurate.
You need to save it in a file with extension as per the model files extension recognised by the simulator.
NOTE: There is no guarantee that the model is accurate - however all simulations that I have done using it seem to be fine.
For components that cannot be modelled directly as above, you can model them as combination of simpler "constituent" components of the device (for example a BJT modelled as a combination of two diode models), but this will generally not be as accurate.
I do not know of any MESFET model. As I said earlier, if no model is available then you have to refer to the device's equivalent circuit (like the way BJTs are represented as two back-to-back diodes or SCRs are represented as a combination of a PNP-NPN pair) and then make up a sub-circuit or model based on the components in the equivalent circuit.
It is possible to create custom SPICE models for components not included in standard libraries, and these models are generally compatible with NGSpice as most simulators support basic SPICE syntax. The accuracy of such models depends heavily on the correctness and completeness of the parameters used, especially for semiconductor devices. For example, a custom BJT model for the MJ3055 transistor was created by modifying an existing power transistor model, demonstrating practical implementation. When direct modeling is not feasible, components can be represented as sub-circuits composed of simpler constituent elements, such as modeling a BJT as two diodes. For rare devices like MESFETs, if no existing model is available, one must refer to the device's equivalent circuit and build a sub-circuit model accordingly. Model files should be saved with the appropriate extension recognized by the simulator. Summary generated by the language model.