It's possible to create custom instruments by feeding X-Plane bitmaps and small text files describing how to use these bitmaps.
However, it's not possible (yet - 9.00 might change that) to define new functionality - basically all you can do is to alter the appearance of the instruments supplied with the X-Plane software.
"Instruments" actually includes everything you can place on an instrument panel - buttons, handles, levers, everything included.
Each instrument requires at least two bitmaps, for example the static "face" of the airspeed indicator and the moving "needle" that indicates the airspeed. Some bitmaps might contain several alternative phases of the same item, for example a rotary magneto/starter switch with several positions (off, L, R, both, start).
This principle remains valid even with the more complex instruments, which layer several layers, possibly with several moving components (such as "needle" and "ball" above each other). Best work your way up from simple switches and dials :-)