Algorithm for designing a binary code with predefined distance Suppose I have a matrix $A$ with its entry $A_{ij}$ denoting some kind of distance between class $i$ and $j$, is there a feasible algorithm for computing a binary coding for all the classes, such that the Hamming distance between code word for $i$ and $j$ is (roughly) proportional to $A_{ij}$?

A related question is that given a set of points, design a binary code where the Hamming distance is (roughly) proportional to the Euclidean distance.
This is known as an embedding into $\{0,1\}^n$.  Your matrix $A$ defines a weighted graph, and you want an embedding into the hypercube.

I suggest you examine the literature on low-distortion graph embeddings, which have been studied in great depth in the computer science literature.  You might find some existing constructions on this topic.  I'm not deeply familiar with that literature myself and I don't know whether you will find anything directly applicable.