**Edit.** In fact, any nontrivial abelian $p$-group $A$ can be realized as the center of a $p$-group with index $p^n$ except in the case $n=1$ (if $A$ is trivial, then it cannot be the center of a nontrivial $p$-group). As has been noted, if $N\subseteq Z(G)$ and $G/N$ is cyclic, then $G$ is abelian, so no group can have a center of prime index. For $n=0$, you can just take $A$ itself.

For $n\gt 1$, we can use the same trick as the one used by [Konstantin Ardakov](https://mathoverflow.net/users/6827/konstantin-ardakov) in the comments: take a group $K$ of order $p^{n+1}$ and class $n$ (such groups are called "$p$-groups of maximal class; I'll give an example below). Such a group $K$ has $Z(K)\cong \mathbf{C}_p$, cyclic of order $p$. Let $k$ be a generator of $Z(K)$. Now let $a\in A$ be an element of order $p$, and take the amalgamated direct product $G=(A\times K)/\langle (a,k^{-1})\rangle$. It is easy to verify that $Z(G)\cong A$, and $G/Z(G)\cong K/Z(K)$, and $K/Z(K)$ has ordder $p^n$. 

Leedham-Green and McKay's **The Structure of Groups of Prime Power Order** (London Math. Soc. Monographs, new series, no. 27), has several examples of $p$-groups of maximal class in Section 3.1. Here are some: for $p=2$ you can take the dihedral, semidihedral, or generalized quaternion groups of order $2^{n+1}$. For odd prime $p$, the analogue of the dihedral group is as follows: let $K_p$ be the $p$th local cyclotomic number field, let $\mathcal{O}$ be its valuation ring, and let $\theta$ be a primitive $p$th root of unity. Let $\mathfrak{p}=(\theta-1)$ be the maximal ideal of $\mathcal{O}$. Then $\mathcal{O}$ is a $C_p$-module, with the generator acting like multiplication by $\theta$. The ideals $\mathfrak{p}^i$ are invariant under the action. We define $\mathbf{E}_{p^n} = (\mathcal{O}/\mathfrak{p}^{n-1})\rtimes \mathbf{C}_p$. This group has maximal class and order $p^{n}$.

(Other examples: $\mathbf{C}_p\wr\mathbf{C}_p$ is a $p$-group of maximal class and order $p^{p+1}$. Or let $A$ be an elementary abelian $p$-group of rank $d$, let $M\in\mathrm{GL}(d,p)$ be the matrix that has $1$s in the diagonal and right above the diagonal, and zeros elsewhere. Then $A\rtimes\langle M_d\rangle$ has maximal class if and only if $3\leq d\leq p$). 

<hr/>

On the other hand, you may want simpler groups, say groups $G$ with $Z(G)\cong A$, $[G:Z(G)]$ of order $p^n$, and $G/Z(G)$ abelian.

An old paper of R. Baer, *Groups with preassigned central and central quotient groups*, Trans. Amer. Math. Soc. **44** (1938), no. 3, 387-412, MR1501973, available on-line [here](http://www.ams.org/journals/tran/1938-044-03/S0002-9947-1938-1501973-3/S0002-9947-1938-1501973-3.pdf), can be used to determine which abelian $p$ groups can be embedded as the center of a group of class two with index $p^n$ for any $n\gt 1$.  The paper considers the problem addressed in the title, and has both an existence and a uniqueness theorem. The existence theorem is restricted to the case in which the central quotient group is a direct sum of cyclic groups, and the uniqueness theorem is further restricted to the case in which the central quotient is finitely generated.

Some notation before stating the main existence result: given an abelian group $A$, $r(A)$ denotes minimum cardinality of a maximal linearly independent subset of $A$ (if $A$ is torsion free or of prime exponent, then any maximal linearly independent subset has $r(A)$ elements, but for more general abelian groups this need not be the case). $A_{t}$ denotes the torsion subgroup of $A$, $A[n]$ the subgroup of elements $x$ such that $nx=0$, and $A(p)$ the subgroup of elements such that $p^ix=0$ for some $i\geq 0$ ($p$ a prime, of course). 

Define $r(A,0)$ to be the rank of $A/A_{t}$, and $r(A,p^i)$ to be the rank of $(p^{i-1}A(p))/(p^iA(p))$

The main result of the paper is:

> **Existence Theorem.** If $A$ is an abelian group and $G$ is a direct sum of cyclic groups, then the following conditions are necessary and sufficient for the existence of a group whose center is $A$ and whose central quotient is isomorphic to $G$:
>
> 1. If $G$ contains elements of order $p^i$, then $A$ contains elements of order $p^i$.
> 2. If $G$ contains elements of infinite order, then $A$ contains elements of infinite order, or the orders of the elements in $G_t$ are not bounded.
> 3. If the orders of the elements in $G_t$ are bounded, and $r(G,0)$ is a finite positive integer, then $A$ contains elements of infinite order and $1\lt r(G,0)$. 
> 4. If the orders of the elements in $G_t$ are bounded, and $r(G,0)$ is an odd positive integer, then $A$ contains two independent elements of infinite order ($r(A,0)\gt 1$).
> 5. If $G=G_t$, $G(p)\neq 0$, and the orders of elements in $G(p)$ are bounded, then $G(p)$ contains at least two independent elements of maximum order.
> 6. If $G=G_t$, and the orders of elements in $G(p)$ are bounded, then if $r(G,p^{i+k})$ is finite with $k\geq 0$ and $r(G,p^i)$ is odd, then $A$ contains two independent elements of order $p^i$ ($r(p^{i-1}A[p])\gt 1$).


So fix $n\gt 1$; if $A$ is an arbitrary nontrivial abelian $p$-group, then let $G$ be the direct sum of $n$ copies of the cyclic group of order $p$. Then 1 is satisfied, 2, 3, and 4 are vacuously true, and $5$ is true. (Note that condition 5 excludes the possibility of index $p$, though that can be derived directly as has been mentioned).

Now, since $G(p)=G$, and $pG=0$, for point 6, note that for any $i\gt 1$ we have $r(G,p^i)=0$; and $r(G,p)=n$; if $n$ is even, then 6 is satisfied vacuously, so you can always obtain a group. You can realize it taking an element $x$ of order $p$ in $A$, letting $G$ be the extraspecial $p$-group of order $p^{2n+1}$ with center generated by $c$, and taking the group $A\times G/\langle (x,z^{-1})\rangle$, an amalgamated direct product; same idea as the construction given by Konstantin Ardakov in the comments.

If $n$ is odd, however, then condition $6$ requires that $A$ contain at least two independent elements of order $p$.

Since a finite abelian group is capable if and only if it is not cyclic and the two largest invariants are equal, if we realize $A$ as the center of a group $B$ with $[B:A]=p^{2k+1}$, then $B$ must be a direct sum of the form $C_{p^{a_1}}\oplus\cdots\oplus C_{p^{a_r}}$ with $r\gt 1$, $a_1\leq a_2\leq\cdots\leq a_r$, and $a_{r-1}=a_r$; so any $G$ we try to use must have at least three cyclic summands, and so picking a different group $G$ to be a central quotient would only put stronger conditions on $A$ (e.g., requiring $A$ to contain at least two independent elements of order $p^i$ for several different $i$).

In summary:

Let $A$ be an abelian $p$-group, not necessarily finite, and let $n\gt 0$. Then $A$ can be realized as the center of a $p$-group $H$ of class $2$ with $[H:A]=p^n$ if and only if: (i) $A$ is trivial and $n=0$; (ii) $A$ is nontrivial and $n$ is even; or (iii) $A$ is nontrivial, $n\gt 1$ is odd, and $A$ has at least two independent elements of order $p$. 

And if $n\neq 1$, then any nontrivial abelian $p$-group $A$ can be realized as the center of a group $G$ with $[G:A]=p^n$.