For DER encoding, you can i2d_DHParams may solve your purpose.
Suppose you have DH parameters in dh, then you can call
int len;
len = i2d_DHParams (dh, &buf);
//It should write encoded dh to buf and len should be number of bytes written.
You can see DH methods here.