Using new command for a tikz draw
Welcome to TeX-SE! Your proposal works nicely if you use scale
to scale the picture down.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand{\test}[1][]{\begin{tikzpicture}[#1]
\draw (0,0)--(1,1);
\draw (0,1) -- (0.5-0.05,0.5+0.05);
\draw (1,0) -- (0.5+0.05,0.5-0.05);
\end{tikzpicture}}
$X_{\test[scale=0.2]}$
\end{document}
However, often one wants to define a new symbol that scales with the text and becomes bold when the surroundings are, adapts the color of is ambient text and so on. Here is a way of achieving this with your command as starting point.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\makeatletter
\DeclareRobustCommand{\checkbold}[1]{% https://tex.stackexchange.com/a/24635/121799
\edef\@tempa{\math@version}\edef\@tempb{bold}%
\ifx\@tempa\@tempb%
\def#1{1}%
\else
\def#1{0}%
\fi}
\makeatother
\newcommand{\somedrawing}{(0,0)--(0.7em,0.7em) (0,0.7em) -- (0.35em-0.07em,0.35em+0.07em)
(0.7em,0) -- (0.35em+0.07em,0.35em-0.07em)}
\newcommand{\myX}{\checkbold\tmp%
\ensuremath{\mathrel{%
\mathchoice{%
\tikz{\draw[line width={1.2*(1+0.33*\tmp)*0.06em}]\somedrawing;}
}{%
\tikz{\draw[line width={1.2*(1+0.33*\tmp)*0.06em}]\somedrawing;}
}{%
\tikz{\draw[line width={1.2*(1+0.33*\tmp)*0.045em}]\somedrawing;}
}{%
\tikz{\draw[line width={1.2*(1+0.33*\tmp)*0.035em}]\somedrawing;}
}}}}
\newcommand{\test}{\begin{tikzpicture}
\draw[line width=0.07ex] ;
\end{tikzpicture}}
\begin{document}
$X_{\myX}$ {\Large $\myX_{\myX}$} {\boldmath $X_{\myX}$ \textcolor{blue}{\Large $\myX_{\myX}$}}
\end{document}
Further information can be found in the answers to this question, and I am using the TikZy answer from there.
Similar to @marmot's answer but the parameter passed (a number) is the scale-down size and you could simply the \test
command without passing any parameters (the scale factor is set to 0.2 by default). Also, I have make the drawing of the command easier, I drew a thick white line and then a smaller black line.
\documentclass[border = 5mm]{standalone}
\usepackage{tikz}
\newcommand{\test}[1][0.2]{%
\begin{tikzpicture}[scale=#1]
\draw[] (0,0)--(1,1);
\draw[very thick, white] (1,0)--(0,1); % The white separation
\draw[] (1,0)--(0,1);
\end{tikzpicture}%
}
\begin{document}
Default size \test, in mathmode: $Something_{\test[0.125]}$.
\end{document}