Here is the answer I got from Dr Stephen N. Henson. OpenSSL project core developer in openssl-users forum:
"The structure ECDSA_SIG is the one you need.
In outline: allocate the structure using ECDSA_SIG_new, set the r and s values using BN_bin2bn, encode the result with i2d_ECDSA_SIG and finally free with ECDSA_SIG_free".